I have a page with a p:selectOneRadio and I want to show one datatable depending on the chosen value of the radio selection. I have the error:
GRAVE: javax.el.MethodNotFoundException: .......changeListenerMethod(javax.faces.event.AjaxBehaviourEvent)
My code is the following:
<p:selectOneRadio value="#{analysisOrderForm.selectedOrderDomain}">
<f:selectItem itemLabel="choice1" itemValue="choice1"></f:selectItem>
<f:selectItem itemLabel="choice2" itemValue="choice2"></f:selectItem>
<p:ajax event="change" listener="#{analysisOrderForm.changeListenerMethod}"/>
</p:selectOneRadio>
<h:PanelGroup>
<p:dataTable rendered="#{analysisOrderForm.selectedOrderDomain == 'choice1'}">....</p:dataTable>
<p:dataTable rendered="#{analysisOrderForm.selectedOrderDomain == 'choice2'}">....</p:dataTable>
</h:PanelGroup>
The code of my 'changeListenerMethod method' is just:
public void changeListenerMethod(ValueChangeEvent e){
setSelectedOrderDomain(e.getValue().toString());
}
What is correct and what is wrong in my code?
When using
JSF will look for a method in your
analysisOrderForm
bean which has the following signature:public void changeListenerMethod(AjaxBehaviourEvent e)
. So you just need to replaceValueChangeEvent
byAjaxBehaviourEvent
.Notes:
public void changeListenerMethod()
and references it in your listener withlistener="#{analysisOrderForm.changeListenerMethod()}
p:selectOneRadio
event should be click (besides, that's the default event value). See also https://stackoverflow.com/a/21292158/2118909