vjkumar
vjkumar

Reputation: 39

Dynamcially adding panels based on DropdownChoice selection

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

Answers (1)

lepike
lepike

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

Related Questions