f:ajax listener method argument

774 Views Asked by At

TODO: Get selected row in h:datatable.

Code Snippet using HtmlDataTable binding:

<h:dataTable value="#{bean.licenses}" var="license" rendered="#{!empty bean.licenses}" binding="#{bean.dataTable}">
  <h:column>
    <h:selectOneRadio onclick="uncheckOthers(this);" >
      <f:selectItem itemValue="null" />
      <f:ajax listener="#{bean.updateSelected}" render="licenseGenerator:submitButtons">
        <f:param name="license" value="#{license}" />
      </f:ajax>
    </h:selectOneRadio>
  </h:column>
</h:dataTable>

So the above mentioned is one way to do it, however since I am already using EL 2.2, I was trying to do something like the accepted answer. and update f:ajax to

<f:ajax listener="#{bean.updateSelected(license)}" render="licenseGenerator:submitButtons">

When I update the code with the above code, the listener is not getting invoked so I checked the documentation which says:

javax.el.MethodExpression (signature must match public void processAjaxBehavior(javax.faces.event.AjaxBehaviorEvent event) throws javax.faces.event.AbortProcessingException)

So, basically with the above signature I can't use something like

public void listener(License license){
    //...
}

However, since it was the accepted answer, I am sure I am missing something here. Thanks for the help!

JSF Version: Mojarra JSF Implementation 2.2.12
Server: Apache Tomcat 8.0.24

0

There are 0 best solutions below