I’ve a problem when I use selectOneRadio and the renderer of my panels.
My cession.xhtml contains this
<p:selectOneRadio id="options" value="#{editionBean.radioProprietaire}">
<f:selectItem itemLabel="Particulier" itemValue="particulier" />
<f:selectItem itemLabel="Societe" itemValue="societe" />
<f:ajax listener="#{editionBean.listener}"/>
</p:selectOneRadio>
<h:panelGroup rendered="#{editionBean.renderSoc}">...</h:panelGroup>
<h:panelGroup rendered="#{editionBean.renderPart}">...</h:panelGroup>
My EditionBean.class
private boolean renderSoc;
private boolean renderPart;
private String radioProprietaire;
public void listener(AjaxBehaviorEvent event) {
if(null != radioProprietaire && radioProprietaire.equals("particulier")){
renderPart = true;
renderSoc = false;
}
else if(null != radioProprietaire && radioProprietaire.equals("societe")){
renderPart = false;
renderSoc = true;
}
}
I know that method listener is call, but ths panels aren’t visible, if someone can help me ?
There are 2 problems.
You need
<p:ajax>instead of<f:ajax>in PrimeFaces components.You need to explicitly specify a JSF component in the ajax update so that it will be re-rendered. With the current approach, you’re basically updating nothing. With
<f:ajax>, the to-be-updated components should be specified inrenderattribute and with<p:ajax>inupdateattribute.Further, there’s some inefficiency going on. You don’t need the listener method and those lot of boolean properties at all. You can just check the radio button value directly in the
renderedattribute.So, all with all, this should do:
See also: