title: How to invoke a bean action method using a link? The onclick does not work
body: <p>I'm trying to implement a list of users names which can be rearranged by clicking on <em>UP</em> or <em>DOWN</em> links.</p>
  
  <pre><code>&lt;ul&gt;
      &lt;ui:repeat var="user" value="#{cc.attrs.value}"&gt;
          &lt;li&gt;
              #{user.name}
              &lt;h:link outcome = "user" value = "left" onclick="#{accountController.moveDown}"&gt;
                  &lt;f:param name="id" value = "${user.id}" /&gt;
              &lt;/h:link&gt;
          &lt;/li&gt;
  
      &lt;/ui:repeat&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>The problem here is that it seems that I'm not using the onclick attribute correctly. What is the proper way for doing this?</p>
  
  <hr>
  
  <p><strong>Edit:</strong> Following your advices I placed all the links in a form:</p>
  
  <pre><code>&lt;h:form&gt;
          &lt;ui:repeat value="#{cc.attrs.value}" var = "user"&gt;
          &lt;div class = "user"&gt;
              &lt;h:commandLink id = "Link1" value = "Up" binding = "#{accountController.ommandLink}" action = "#{accountController.moveUserUp}"&gt;
                  &lt;f:attribute name = "userId" value = "#{user.id}" /&gt;
              &lt;/h:commandLink&gt;
              &lt;h:commandLink id = "Link2" value = "Down" binding = "#{accountController.commandLink}" action = "#{accountController.moveUserDown}"&gt;
                  &lt;f:attribute name = "userId" value = "#{user.id}" /&gt;
              &lt;/h:commandLink&gt;
              &lt;h:commandLink id = "Link3" value = "Delete" binding = "#{accountController.commandLink}" action = "#{accountController.deleteUser}"&gt;
                  &lt;f:attribute name = "userId" value = "#{user.id}" /&gt;
              &lt;/h:commandLink&gt;
      &lt;/div&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>the Managed Bean:</p>
  
  <pre><code>private UIComponent commandLink;
  
  public void moveUserUp(){
      Integer userId = (Integer)commandLink.getAttributes().get("userId");
      System.out.println("MOVE TAB LEFT :" + userId);
  }
  
  public void moveUserDown(){
      Integer userId = (Integer)commandLink.getAttributes().get("userId");
      System.out.println("MOVE TAB RIGHT: " + userId);
  }
  
  public void deleteUser(){
      Integer userId = (Integer)commandLink.getAttributes().get("userId");
      System.out.println("DELETE TAB: " + userId);
  }
  
  public UIComponent getCommandLink() {
      return commandLink;
  }
  
  public void setCommandLink(UIComponent commandLink) {
      this.commandLink = commandLink;
  }
  </code></pre>
  
  <p>The communication between the command Link and the managed bean is working but in the UI only the last commandLink (close action) is displayed.</p>