Project

General

Profile

Actions

Support #1328

closed

dynamic links

Added by Paweł Grzybowski almost 12 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
-
Start date:
06/19/2012
Due date:
% Done:

0%

Estimated time:

Description

Hi,

I would like to know how to make dynamic links and dynamic for example WPushButton.

Actions #1

Updated by Wim Dumon almost 12 years ago

Not sure what you want. Can you give an example?

Actions #2

Updated by Paweł Grzybowski almost 12 years ago

I don't know how to make it in wt so I give you an example in PHP

for($i;$i<10;$i) {echo'Next'};

and the second example in PHP

for($i;$i<10;$i) {echo '';}

Actions #3

Updated by Paweł Grzybowski almost 12 years ago

I don't know how to make it in wt so I give you an example in PHP

for($i;$i<10;$i) {echo'Next'};

and the second example in PHP

for($i;$i<10;$i) {echo '';}

Actions #4

Updated by Paweł Grzybowski almost 12 years ago

I don't know how to make it in wt so I give you an example in PHP

for($i;$i<10;$i) {echo'Next'};

and the second example in PHP

for($i;$i<10;$i) {echo '';}

Actions #5

Updated by Wim Dumon almost 12 years ago

The equivalent would be:

for(int i = 0; i < 100; ++i)
  new WAnchor("next.php?w=" + std::lexical_cast<std::string>(i), "Next", this);

That's for the case that you want your anchor to point to whatever URL's (in this case: some php that could be anywhere).

Using buttons, allow me to demonstrate Wt's style of responding to events, such as mouse clicks:

MyWidgt::MyWidget(/* parameters come here */)
{
  for(int i = 0; i < 100; ++i) {
    WPushButton *b = new WPushButton("Button " + boost::lexical_cast<std::string>(i), this);
    // When button is clicked, call buttonClicked with parameter i identifying the clicked button
    b->clicked().connect(boost::bind(&MyWidget::buttonClicked, this, i));
  }
}

void MyClass::buttonClicked(int i)
{
  // Write anything that you want to happen when someone clicks the button here
  // In this case: add extra text to the DOM
  new WText("You clicked button " + boost::lexical_cast<std::string>(i), this);
}
Actions #6

Updated by Koen Deforche almost 12 years ago

  • Status changed from New to InProgress
  • Assignee set to Wim Dumon
Actions #7

Updated by Wim Dumon over 11 years ago

  • Status changed from InProgress to Closed
Actions

Also available in: Atom PDF