wicket.markup.html.link.Link
[back to the reference]Links are your basic call back mechanism. You can attach links to any element you want. See Link-o-matic for more link examples.
Here is a normal link, attached to an anchor:
this link is clicked 0 times
Same as above, but this time a link that records a state change.
this link is clicked 0 times
And here is a link attached to a button element, with a nested label:
But you could also attach a link to an input/button element, and attach an AttributeModifier
to it to display the number of clicks:
Behind the Scenes
Example HTML
<a href="#" wicket:id="link1">this link is clicked <span wicket:id="label1">n</span> times</a>
Example Code
final Count count1 = new Count(); // simple counter object
Link link1 = new Link("link1") {
public void onClick() {
count1.increment();
}
};
link1.add(new Label("label1", new Model<String>() {
public Object getObject() {
return count1.toString();
}
}));
add(link1);