Reputation: 39
am a newbie to wicket and am experimenting few things with it, like, I have four panel but one only should be added based on the selection made in the DropdownChoice component. i tried to add panels using onSelectChange() method, but it doesn't work. can any one please help me out with proper sample code.
Upvotes: 0
Views: 1723
Reputation: 745
I give you an example for this problem. Hope it helps.
DropDownChoice dropDown = new DropDownChoice(...........);
AjaxFormComponentUpdatingBehavior behavior = new AjaxFormComponentUpdatingBehavior(
"onchange") {
@Override
protected void onUpdate(AjaxRequestTarget target) {
//you should write here the logic that
// replaces the panel, something like: content.addOrReplace(panel)
target.addComponent(form);
}
};
dropDown.add(behavior);
So that's all, you have to use AjaxFormComponentUpdatingBehavior to handle onchange event. If the dropdown menu not a requirement, you can use tabbedpanel. Here you can find the sample code: wicket tabbed panel
Upvotes: 5