2 Replies Latest reply on Mar 19, 2010 8:09 AM by Ilya Shaikovsky

    a4j:jsFunction with actionListener inside of h:dataTable

    Ben Reich Newbie

      Hello all,

      I'm having problem with using  a4j:jsFunction with actionListener inside of h:dataTable, when I want to  invoke an action over particular row with a4j:commandLink it works  flawless but when I want to invoke the action with a4j:jsFunction &  actionListener it's always invoked over the last element in dataTable

      Let me  give you an example:



      {code:xml}<a4j:form ajaxSubmit="true"  reRender="mainForm" id="mainForm">


      <t:saveState  value="#{ts.list}" />



      <h:dataTable  value="#{ts.list}" var="el" binding="#{ts.bind}">



      <a4j:commandLink  actionListener="#{ts.rem}">

      <h:outputText value="delete by  CMDLink" />




      <a  href="#" onclick="okClicked();">delete by okClicked</a>

      <a4j:jsFunction name="okClicked"









      package  com.sth;


      import java.util.ArrayList;

      import  java.util.List;


      import  javax.faces.component.UIData;

      import  javax.faces.event.ActionEvent;


      public  class Ts {


      private List<String> list =  new ArrayList<String>();

      private UIData bind;


      public  Ts(){







      public  List<String> getList() {

      return list;



      public  void setList(List<String> list) {

      this.list = list;



      public  void rem(ActionEvent ae) {

      String toRem = (String)  bind.getRowData();

      System.out.println("Deleting " +  toRem);




      public  UIData getBind() {

      return bind;



      public  void setBind(UIData bind) {

      this.bind = bind;






      When I use  a4j:commandLink to remove element, it works as its expected, but when I  use a4j:jsFunction to invoke actionListener it invokes action against  last element

      Any ideas?