0

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

Community
  • 1
  • 1
dShringi
  • 1,497
  • 2
  • 22
  • 36
  • Tell JSF and server impl/version. At least, this problem is not reproducible in current latest versions. I'd guess a version conflict somewhere, or you've actually not tested the so far posted code in a MCVE setup. – BalusC Jan 12 '16 at 08:26
  • @BalusC I have posted the question after trying it myself. Unless the object passed in argument has AjaxBehaviourEvent as super class how is it possible to invoke the listener when it doesn't matches the specified method signature. – dShringi Jan 12 '16 at 11:32
  • I can imagine a similar fail when used incorrectly in a composite component, but this clue is nowhere visible in the information provided so far. Code doesn't seem to be in MCVE format and there's no stack trace. – BalusC Jan 12 '16 at 11:48
  • This works for me in WF 8.x and 10 CRx. Need more information – thatsIch Jan 12 '16 at 21:24
  • Not sure of the reason but when I removed f:param nested inside f:ajax, it worked for me. – dShringi Jan 13 '16 at 04:37

0 Answers0