I try to display an <a4j:outputPanel>
if a value was selected in a picklist
My html, the first picklist trigger the event to reRender the second picklist
<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>
And there is the test() function in controller:
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;
}
}
When I pick the item with ID 2 in the pick list, my function is called and it return true, but the second pick list still not display
Thank you, and sorry for english mistaken note i am a newbie in all of this
Zel'
I finally found the answer on this : JSF ReRender support with selectBooleanCheckbox
So there is the correct code, the target of Rerender have change and I have put my element to display in a wrapper.
<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>