JSF,a4j:支持和丰富:pickList,rerender

时间:2016-06-08 08:12:25

标签: jsf richfaces ajax4jsf picklist

如果在选项列表中选择了值

,我会尝试显示<a4j:outputPanel>

我的html,第一个选项列表触发事件给reRender第二个选项列表

                                <li class="clearfix"><label class="desc"><sup>*</sup>
                                        <h:outputText value="Services :" /></label>
                                    <div>
                                        <span class="full"> <rich:pickList id="pickService"
                                                value="#{GroupeController.listServices}"
                                                copyAllControlLabel="Tout copier"
                                                removeAllControlLabel="Tout supprimer"
                                                copyControlLabel="Copier" removeControlLabel="Supprimer">



                                                <a4j:support event="onlistchange" ajaxSingle="true" reRender="test" />



                                                <f:selectItems
                                                    value="#{GroupeController.getListTypeGroupeServices()}" />
                                                <f:facet name="copyAllControlDisabled">Tout copier
                                                </f:facet>
                                                <f:facet name="removeAllControlDisabled">Tout supprimer
                                                </f:facet>
                                                <f:facet name="copyControlDisabled">Copier
                                                </f:facet>
                                                <f:facet name="removeControlDisabled">Supprimer
                                                </f:facet>
                                            </rich:pickList>
                                        </span> <label><rich:message errorLabelClass="req"
                                                for="pickService" /></label>
                                    </div></li>
                            </a4j:outputPanel>





                            <a4j:outputPanel id="test" rendered="#{GroupeController.test()}" >
                                <li  class="clearfix"><label class="desc">
                                        <h:outputText value="ACL existantes :" /></label>
                                    <div>
                                        <span class="full"> <rich:pickList id="pickACL"
                                                value="#{GroupeController.listACLSelect}"
                                                copyAllControlLabel="Tout copier"
                                                removeAllControlLabel="Tout supprimer"
                                                copyControlLabel="Copier" removeControlLabel="Supprimer">
                                                <f:selectItems
                                                    value="#{GroupeController.getAllACL()}" />
                                                <f:facet name="copyAllControlDisabled">Tout copier
                                                </f:facet>
                                                <f:facet name="removeAllControlDisabled">Tout supprimer
                                                </f:facet>
                                                <f:facet name="copyControlDisabled">Copier
                                                </f:facet>
                                                <f:facet name="removeControlDisabled">Supprimer
                                                </f:facet>

                                            </rich:pickList>
                                        </span> <label><rich:message errorLabelClass="req"
                                                for="pickACL" /></label>
                                    </div></li>
                            </a4j:outputPanel>
                        </a4j:outputPanel>
                        <a4j:commandButton id="idAjouter" value="Ajouter"
                            action="#{GroupeController.ajouterGroupe()}"
                            onclick="#{rich:component('wait')}.show()" reRender="form,error"
                            limitToList="true" oncomplete="#{rich:component('wait')}.hide()" />
                    </rich:panel>
                </a4j:outputPanel>
            </h:form>
        </rich:layoutPanel>

控制器中有test()函数:

public boolean test() {

    if (listServices == null) {
        return false;
    } else {

        boolean test = false;
        for (String s : listServices) {
            if (Integer.parseInt(s) == 2) {
                test = true;
            }
        }

        return test;

    }
}

当我在选择列表中选择ID为2的项目时,我的函数被调用并返回true,但第二个选择列表仍未显示

谢谢你,对不起英语错误的说明我是所有这一切的新手

ZEL'

1 个答案:

答案 0 :(得分:0)

我终于找到了答案:JSF ReRender support with selectBooleanCheckbox

所以有正确的代码,Rerender的目标已经改变,我已经将我的元素显示在包装器中。

<a4j:outputPanel>

                                <li class="clearfix"><label class="desc"><sup>*</sup>
                                        <h:outputText value="Services :" /></label>
                                    <div>
                                        <span class="full"> <rich:pickList id="pickService"
                                                value="#{GroupeController.listServices}"
                                                copyAllControlLabel="Tout copier"
                                                removeAllControlLabel="Tout supprimer"
                                                copyControlLabel="Copier" removeControlLabel="Supprimer">
                                                <a4j:support event="onlistchange" ajaxSingle="true" reRender="testWrapper" />
                                                <f:selectItems
                                                    value="#{GroupeController.getListTypeGroupeServices()}" />
                                                <f:facet name="copyAllControlDisabled">Tout copier
                                                </f:facet>
                                                <f:facet name="removeAllControlDisabled">Tout supprimer
                                                </f:facet>
                                                <f:facet name="copyControlDisabled">Copier
                                                </f:facet>
                                                <f:facet name="removeControlDisabled">Supprimer
                                                </f:facet>
                                            </rich:pickList>
                                        </span> <label><rich:message errorLabelClass="req"
                                                for="pickService" /></label>
                                    </div></li>
                            </a4j:outputPanel>
                            <h:panelGroup id="testWrapper">
                                <a4j:outputPanel id="test" rendered="#{GroupeController.test()}" >
                                    <li  class="clearfix"><label class="desc">
                                            <h:outputText value="ACL existantes :" /></label>
                                        <div>
                                            <span class="full"> <rich:pickList id="pickACL"
                                                    value="#{GroupeController.listACLSelect}"
                                                    copyAllControlLabel="Tout copier"
                                                    removeAllControlLabel="Tout supprimer"
                                                    copyControlLabel="Copier" removeControlLabel="Supprimer">
                                                    <f:selectItems
                                                        value="#{GroupeController.getAllACL()}" />
                                                    <f:facet name="copyAllControlDisabled">Tout copier
                                                    </f:facet>
                                                    <f:facet name="removeAllControlDisabled">Tout supprimer
                                                    </f:facet>
                                                    <f:facet name="copyControlDisabled">Copier
                                                    </f:facet>
                                                    <f:facet name="removeControlDisabled">Supprimer
                                                    </f:facet>

                                                </rich:pickList>
                                            </span> <label><rich:message errorLabelClass="req"
                                                    for="pickACL" /></label>
                                        </div></li>
                                </a4j:outputPanel>
                            </h:panelGroup>