0 Replies Latest reply on Feb 16, 2012 9:33 AM by rob san

    <a4j:param> always 0

    rob san Newbie

      Hello guys,

       

      I try to use the <a4j:param> tag inside an <a4j:commandlink> to store a Value in my Userbean! But the Value printed out from function remove() (confirmPane) is always 0!

       

      heres my code(Page):

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:a4j="http://richfaces.org/a4j"
                      xmlns:rich="http://richfaces.org/rich">

       

          <rich:dataTable value="#{usermanager.userList}" var="users"
                  iterationStatusVar="it" id="table" rows="15">
              <rich:column>
                  <f:facet name="header"># </f:facet>
                  #{it.index}
              </rich:column>
              <rich:column>
                  <f:facet name="header">
                      <h:outputText value="Firstname"/>
                  </f:facet>
                  <h:outputText value="#{users.firstname}"/>
              </rich:column>
              <rich:column>
                  <f:facet name="header">
                      <h:outputText value="Lastname"/>
                  </f:facet>
                  <h:outputText value="#{users.lastname}"/>
              </rich:column>
              <rich:column>
                  <f:facet name="header">
                      <h:outputText value="Username"/>
                  </f:facet>
                  <h:outputText value="#{users.username}"/>
              </rich:column>
              <rich:column>
                  <f:facet name="header">
                      <h:outputText value="Registrationdate"/>
                  </f:facet>
                  <h:outputText value="#{users.since}"/>
              </rich:column>
              <rich:column>
                  <f:facet name="header">
                      <h:outputText value="Active"/>
                  </f:facet>
                  <h:outputText value="#{users.active}"/>
              </rich:column>
              <rich:column>
                  <a4j:commandLink  value="delete" styleClass="no-decor" execute="@this"
                          render="@none" oncomplete="#{rich:component('confirmPane')}.show()">
                      <a4j:param name="userindex" value="#{it.index}"
                                 assignTo="#{usermanager.currentUserIndex}"  />
                  </a4j:commandLink>
                  </rich:column>
                 
          </rich:dataTable>

       

      <a4j:jsFunction

              name="remove" action="#{usermanager.remove}"

              render="table" execute="@this"

              oncomplete="#{rich:component('confirmPane')}.hide();"

              />

       

         <rich:popupPanel id="confirmPane" modal="false" autosized="true">

              Are you sure you want to delete the row?

              <a4j:commandButton value="Cancel" onclick="#{rich:component('confirmPane')}.hide(); return false;"/>

              <a4j:commandButton value="Delete" onclick="remove();return false;"/>

              <h:messages style="color: red" globalOnly="true"/>

          </rich:popupPanel>

       

      and the bean:

       

      import java.util.ArrayList;
      import java.util.Date;
      import java.util.List;
      import java.util.Map;
      import java.util.logging.Level;
      import java.util.logging.Logger;
      import javax.annotation.Resource;
      import javax.faces.application.FacesMessage;
      import javax.faces.context.FacesContext;
      import javax.persistence.EntityManager;
      import javax.persistence.NoResultException;
      import javax.persistence.PersistenceContext;
      import javax.servlet.http.HttpSession;
      import javax.transaction.UserTransaction;

      /**
      *
      * @author IMS_Trial
      */
      public class UserManager {
         
          public static final String USER_SESSION_KEY = "user";
         
          @PersistenceContext
          private EntityManager em;
         
          @Resource
          private UserTransaction utx;
            
          private String editUser;
          private String username;
          private String password;
          private String passwordv;
          private String fname;
          private String lname; 
          private boolean active;
          private int currentUserIndex;

          public int getCurrentUserIndex() {
              return currentUserIndex;
          }

          public void setCurrentUserIndex(int currentUserIndex) {
              this.currentUserIndex = currentUserIndex;
          }
          private List<Wuser> userlist= new ArrayList<Wuser>();
       
        
          // -------------------------------------------------------------- Properties
            public boolean isActive() {
              return active;
          }

          public void setActive(boolean active) {
              this.active = active;
          }
          public String getEditUser() {
              return editUser;
          }

          public void setEditUser(String editUser) {
              this.editUser = editUser;
          }
            
         
         
          public String getUsername() {
             return username;
          }
         
         
          public void setUsername(String username) {
              this.username = username;
          }
         
          public String getPassword() {
              return password;
          }
         
        public void remove(){
           System.out.println(this.currentUserIndex);
           
           
        } 

       

       

      thx!