更改下拉列值时更改禁用选项卡的类别

时间:2017-10-20 12:49:56

标签: java jquery css wicket wicket-6

我有1个下拉列表,基于下拉值选项卡将启用或禁用。默认情况下,我对所有选项卡使用getTabContainerCssClass(),它会将所有选项卡显示为启用视图,但我想更改选项卡css类,因为它在更改下拉列值后看起来像是禁用。

 setUp(scen inject atOnceUsers(usersNumber)) protocols httpConf

关于这个的任何想法......

更新:更新代码后

DropDownChoice ProductDropDown = new DropDownChoice("ProductList", new PropertyModel(this, "SupplierProduct"),ProductList, new choiceRenderer("name","id"));
add(supplierProductDropDown);

supplierProductDropDown.add(new AjaxFormComponentUpdatingIndicatingBehavior("onchange"){
            @Override
            protected void onUpdate(AjaxRequestTarget target) {
                 /* do some code for changing dropdown */
            }
      });

tabs = new ArrayList<AbstractTab>();

/* provide some tab details */

tab = new AjaxTabbedPanel("tabs", tabs){

        private static final long serialVersionUID = 1L;

        @Override
        protected String getTabContainerCssClass() {
            return "producttab-row";
        }
        @Override
        protected WebMarkupContainer newLink(String linkId, final int index) {

            return new Link(linkId)
            {
                    private static final long serialVersionUID = 1L;

                    public void onClick() {
                            setSelectedTab(index);
                    }

                    @Override
                    public boolean isEnabled() {
                        if(index == 1 && /*drop down condition that will be disable the tab*/){
                            /*I want to change css of this tab*/
                            return false;
                        }
                        else{
                            return true;
                        }
                    }
            }
       }
}

但它并没有对此有所帮助。请帮忙

解决方案:我在AjaxTabbedPanel.see中覆盖了onComponentTag,代码如下

 @Override
                    protected void onComponentTag(final ComponentTag tag) {
                    // TODO Auto-generated method stub
                        super.onComponentTag(tag);
                        if(/*Dropdown condition*/){

                             tag.append("class", "disabletab", " ");
                         }
}

1 个答案:

答案 0 :(得分:2)

您应该覆盖Link#onComponentTag(ComponentTag)方法并将CSS类设置为:tag.append("class", "dynamicValueDependingOnDropDownsModel", " ")