You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Muro Copenhagen <co...@gmail.com> on 2010/03/09 12:46:18 UTC
Refreshing dropdownchoice that is ajax enabled
Hi,
I have a small problem i hope someone has an answer for.
I have a textfield that can only be visible when a certain dropdownchoice
option is selected....
My code is as:
// special doctor info
final TextField infoField = new TextField("info");
infoField .setOutputMarkupId(true);
infoField .setOutputMarkupPlaceholderTag(true);
add(infoField.setVisible(false));
DropDownChoice dropDownChoice = new
EDropDownChoice("departments", new Model(department) {
@Override
public Department getObject() {
return department;
}
@Override
public void setObject(Serializable object) {
if (object != null) {
department = (Department) object;
}
}
}, departmentService.getAll(), new ChoiceRenderer("department",
"id"));
dropDownChoice.add(new
AjaxFormComponentUpdatingBehavior("onchange") {
protected void onUpdate(AjaxRequestTarget target) {
infoField.setVisible(department.equals("test"));
target.addComponent(infoField);
}
});
add(dropDownChoice);
It all works fine, except on browser refresh.
The problem occurs when the choice "test" is selected, the textfield gets
visible.
Then if i refresh the browser the textfield dissappears...
But if i submit the form before refreshing the textfield that is visible
will not dissappear.
Can anyone explain why the textfield dissappears ?
Best Regards
Muro