Reputation: 2318
I tried to hide a label as follows :
Form form = new Form("form");
Label myLabel = new Label("myLabel", new ResourceModel("mylabel.text").getObject());
if(hide == true){
myLabel.setVisible(Boolean.FALSE);
}
form.add(myLabel);
..
but the label still appears. Does anyone know why?
Upvotes: 1
Views: 4497
Reputation: 2939
Informations below are for Wicket 1.4 (quite old now).
For Wicket 1.5 and 6.x (aka 1.6) the right way is override component's onConfigure()
and call setVisible()
from there:
@Override
protected void onConfigure()
{
super.onConfigure();
boolean flag = myDbDAO.getVisibilityOfThisPanel()
this.setVisible(flag);
}
Keep component.isVisible()
light, it should be called more than once per request so long-computing-task there will slow page/panel loading. Put heavy process (DB, math) in onConfigure()
and from there call isVisible()
if needed.
Upvotes: 0
Reputation: 6685
You should override the isVisible method of your label.
Label label = new Label(...) {
@Override
public boolean isVisible() {
return !hide;
}
};
form.add(...)
...
Upvotes: 5
Reputation: 3583
actually you are making invisible the label, the problem is redraw the html page,what you can do it refreshing the page or with help of ajax
Upvotes: 0