根据DropdownChoice选择动态添加面板

| 是wicket的新手,并且正在尝试做一些事情,例如,我有四个面板,但仅应基于DropdownChoice组件中的选择添加一个面板。 我试图使用onSelectChange()方法添加面板,但是它不起作用。有人可以帮我提供适当的示例代码吗?     
已邀请:
        我给你举个例子解决这个问题。希望能帮助到你。
    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);
就是这样,您必须使用AjaxFormComponentUpdatingBehavior来处理onchange事件。如果下拉菜单不是必需的,则可以使用tabbedpanel。在这里您可以找到示例代码:wicket选项卡式面板     

要回复问题请先登录注册