5 Replies Latest reply on Aug 28, 2013 4:56 PM by Brian Leathem

    RF4: a4j:jsFunction and a4j:param

    Alexandre Granier Newbie



      I need to retrieve wich node has been clicked. I use the jsFunction tag with a param like this


                  <a4j:jsFunction name="func" actionListener="#{myBean.action}" render="@form">
                      <a4j:param name="param1" assignTo="#{myBean.idx}"/>
                  <a4j:repeat value="#{myBean.nodes}" var="node" rowKeyVar="key" rows="30">
                      <a4j:outputPanel id="panel" layout="block" onclick="func(#{key});">
                          <h:outputText value="#{node.label}  key: #{key}"/>


      Here is the managed bean


      public class MyBean {
          private List<Node>     nodes;
          private long idx;
      public MyBean() {
              nodes = new ArrayList<Node>();
              nodes.add(new Node("node1"));
              nodes.add(new Node("node2"));
      public void action(ActionEvent event) {
           System.out.println("action "+this.getIdx());



      When the click event occur on the label, the index is passed to the bean.

      It works but the index is the one of the last request...


      As a work around I can get the param using the FacesContext object



      but why this behavior ?