Can any one please let me know how can i add ajax behaviour to dynamically created SelectOneRadio. The Requirement is when i select any one of the radio button ,i want to display jsf dynamically created fieldset. I tried the below .But no luck!!!!Can anybody help on this ????
AjaxBehavior ajax=(AjaxBehavior) FacesContext.getCurrentInstance().getApplication().createBehavior(AjaxBehavior.BEHAVIOR_ID);
ajax.addAjaxBehaviorListener(new CustomAjax());
ajax.setTransient(true);
radio.addClientBehavior("change",ajax);
public class CustomAjax implements AjaxBehaviorListener{
@Override
public void processAjaxBehavior(AjaxBehaviorEvent arg0)
throws AbortProcessingException {
System.out.println("Ajax :"+arg0.getComponent());
}
}
Using JSF2 and primefaces 3.4.1
I tried the solution given by user2251135....no luck.. Let me clarify the question : I want to get the below xhtml functionality programmatically:
<p:selectOneRadio id="customRadio" value="#{test.panel1}"
layout="pageDirection">
<f:selectItem itemLabel="Option 1" itemValue="1" />
<f:selectItem itemLabel="Option 2" itemValue="2" />
<f:selectItem itemLabel="Option 3" itemValue="3" />
<p:ajax update="payment-amount-panel" />
</p:selectOneRadio>
<h:panelGroup id="payment-amount-panel">
<p:fieldset legend="Legend1" rendered="#{test.panel1 == '1'}">
<h:outputText value="Francis Ford Coppola's1 " />
</p:fieldset>
<p:fieldset rendered="#{test.panel1 == '2'}">
<h:outputText value="Francis Ford Coppola's2" />
</p:fieldset>
<p:fieldset rendered="#{test.panel1 == '3'}">
<h:outputText value="Francis Ford Coppola's3" />
</p:fieldset>
</h:panelGroup>
And Bean
@ManagedBean (name="test")
@ViewScoped
public class Test {
private String panel1;
public void setPanel1(String panel1){
this.panel1 = panel1;
}
public String getPanel1(){
return this.panel1;
}
}
Firstly ,thanks user2251135 for the reply on the question.
Can anyone of you be kind enough to help me on this?