Hi to all!
I am new to Wicket and am beginning to love it.
I have the following question:
--------------
There's the following markup:
<p>
<a href="#" wicket:id="clickAjaxLink">This Ajax link</a> has
been clicked <span wicket:id="clickAjaxLabel">[123]</span> times.<br/>
<span wicket:id="ghost">[VISIBLE ONLY WHEN LINK WAS CLICKED AT
LEAST ONCE]</span>
</p>
--------------
and the following corresponding Java code:
public class HelloPage extends WebPage {
int counter;
Label ghostLabel;
Label clickLabel;
public HelloPage() {
add(new AjaxFallbackLink("clickAjaxLink") {
@Override
public void onClick(AjaxRequestTarget target) {
counter++;
if(target != null) {
target.addComponent(clickLabel);
target.addComponent(ghostLabel);
}
}
});
// clickLabel displays how many times the link was clicked
clickLabel = new Label("clickAjaxLabel", new PropertyModel(this,
counter));
clickLabel.setOutputMarkupId(true);
add(clickLabel);
// ghostLabel should be visible only when the link was clicked at
least once
ghostLabel = new Label("ghost", "I should be visible only when the
link was clicked at least once") {
@Override
public boolean isVisible() {
return counter > 0;
}
};
add(ghostLabel);
}
}
---------------
clickLabel works properly and displays the value of counter. But my aim with
ghostLabel is that it is visible only when the AjaxFallbackLink was clicked
at least once. I added it to the request target so that it should be
updated. However, it remains invisible. How can I solve this problem?
Thanks in advance!