1 2 Previous Next 25 Replies Latest reply on Nov 12, 2009 6:16 AM by nbelaevski

    unable to catch <h:commandButton> action event while using w

    sumeet.singh

      Hi,
      I am using <rich:listShuttle> in my <h:form>. <rich:listShuttle> display the sourceValue as well as the targetValue properly. I also used the <h:commandButton> in the same form. I want to get the latest values targetValue in my managed bean class; for this i have provided the callback method and attached it as an action method to my commandButton. however it never gets called.

      <h:form id="idFrm">
      <rich:listShuttle id="listShuttle1" sourceValue="#{RoleReAssignment.lstAvailableRoles}" targetValue="#{RoleReAssignment.lstCurrentRoles}" var="items" listsHeight="150" sourceListWidth="130" targetListWidth="130" sourceCaptionLabel="Available Roles" targetCaptionLabel="Currently Assigned Roles" converter="GeneralConverter" targetRequired="true" sourceRequired="true" >
      
       <rich:column>
       <h:outputLabel value="#{items.strRoleName}"></h:outputLabel>
       </rich:column>
       <a4j:support event="oncomplete, onclick" reRender="frmRoleRevokeAndGrant"/>
       </rich:listShuttle><br/>
       <h:commandButton id="cmdSave" value="Save Details" styleClass="btn" action="#{RoleReAssignment.roleRevokeAndGrant}"/>
      </h:form>



      Bean method name is: roleRevokeAndGrant



        • 1. Re: unable to catch <h:commandButton> action event while usi
          sumeet.singh

          when i click on my command button i got the following error:

          "Component frmRoleRevokeAndGrant:listShuttle1 has invalid value expression [com.test.smp.pojo.SmpRoleNames@1ceea9d]"


          SmpRoleNames is my POJO class having roleId and RoleName as a parameters.

          the targetValue and sourceValue linked with properties having datatype ArrayList

          • 2. Re: unable to catch <h:commandButton> action event while usi
            ilya_shaikovsky

            read please limitations regarding converter implementation required for component and equals/hasCode methods proper implementation for object.

            richfaces-demo has samples which could be downloaded from anonimous SVN. (links at wiki and project site)

            • 3. Re: unable to catch <h:commandButton> action event while usi
              sumeet.singh

              Hi,
              thanks for your reply. I checked the same but still facing the same error. I implemented the hascode and the equals method also but still facing the same problem

              • 4. Re: unable to catch <h:commandButton> action event while usi
                sumeet.singh

                hi,
                where to find "limitations regarding converter implementation required for component"?

                • 5. Re: unable to catch <h:commandButton> action event while usi
                  nbelaevski

                  Look at user guide.

                  • 6. Re: unable to catch <h:commandButton> action event while usi
                    sumeet.singh

                    I checked the same but still facing the same error. I implemented the hascode and the equals method also but still facing the same problem

                    • 7. Re: unable to catch <h:commandButton> action event while usi
                      sumeet.singh

                      hi,
                      I even tried the following solution but still facing the same problem:

                      https://jira.jboss.org/jira/browse/RF-6951

                      I think there is some thing wrong with component listshuttle.

                      The examples currently available does not have the command button in it.

                      I want to retrieve the targetValue values after clicking on the Command button. I want to process and stores the value of targetValue in database.

                      Please help

                      • 8. Re: unable to catch <h:commandButton> action event while usi
                        nbelaevski

                        Check if there are any messages generated.

                        • 9. Re: unable to catch <h:commandButton> action event while usi
                          sumeet.singh

                          hi,
                          i got a message:

                          Component frmRoleRevokeAndGrant:listShuttle1 has invalid value expression [com.test.smp.pojo.SmpRole
                          Names@1ceea9d]


                          Don't you think that there is some problem with listShuttle component.

                          I want to retrieve the targetValue values after clicking on the Command button. I want to process and stores the value of targetValue in database.

                          • 10. Re: unable to catch <h:commandButton> action event while usi
                            nbelaevski

                            What is bean code?

                            • 11. Re: unable to catch <h:commandButton> action event while usi
                              sumeet.singh

                              My Mannaged bean is :

                              public class RoleReAssignment
                              {
                               // Instance Variables
                               private String strNewRoleId;
                               private String strUserName;
                               private List<SmpRoleNames> lstCurrentRoles = new ArrayList<SmpRoleNames>();
                               private List<SmpRoleNames> lstAvailableRoles = new ArrayList<SmpRoleNames>();
                              
                              
                               // Zero Argument constructor
                               public RoleReAssignment()
                               {
                               HttpServletRequest rq = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
                               HttpSession sess = CommonMethods.fetchSession(rq);
                               if(sess!=null && sess.getAttribute("USERNAME_REASSIGNMENT")!=null)
                               {
                               String username = (String)sess.getAttribute("USERNAME_REASSIGNMENT");
                              
                               if(username!=null)
                               {
                               if(!username.equals("DEFAULT"))
                               {
                               SmpRoleModel objRoleModel = new SmpRoleModel();
                               this.lstCurrentRoles = objRoleModel.fetchRoleIdAndNameRelatedToUser(username, true);
                               this.lstAvailableRoles = objRoleModel.fetchRoleIdAndNameRelatedToUser(username, false);
                               this.strUserName = username;
                               sess.removeAttribute("USERNAME_REASSIGNMENT");
                               }
                               }
                               }
                               }
                              
                              
                              
                              
                              
                               //Getter and setters
                               public String getStrNewRoleId() {
                               return strNewRoleId;
                               }
                               public void setStrNewRoleId(String strNewRoleId) {
                               this.strNewRoleId = strNewRoleId;
                               }
                               public List<SmpRoleNames> getLstCurrentRoles() {
                               return lstCurrentRoles;
                               }
                              
                               public void setLstCurrentRoles(List<SmpRoleNames> lstCurrentRoles) {
                               this.lstCurrentRoles = lstCurrentRoles;
                               }
                              
                               public List<SmpRoleNames> getLstAvailableRoles() {
                               return lstAvailableRoles;
                               }
                              
                               public void setLstAvailableRoles(List<SmpRoleNames> lstAvailableRoles) {
                               this.lstAvailableRoles = lstAvailableRoles;
                               }
                              
                               public String getStrUserName() {
                               return strUserName;
                               }
                               public void setStrUserName(String strUserName) {
                               this.strUserName = strUserName;
                               }
                               //Business logic methods
                              
                               public String roleRevokeAndGrant()
                               {
                               System.out.println("HI FROM roleRevokeAndGrant ===============>");
                              
                               System.out.println("CURRENTLY SELECTED ROLES ==> "+this.lstCurrentRoles);
                               return "";
                               }
                              
                               //Action Listener
                               /**
                               * @comment : Method to fetch the details according to user name
                               * @return
                               */
                               public void fetchDetailsAccordingToUserName(ActionEvent evt)
                               {
                               HttpServletRequest rq = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
                               String username = rq.getParameter("frmRoleRevokeAndGrant:USERNAME");
                               HttpSession sess = CommonMethods.fetchSession(rq);
                               sess.setAttribute("USERNAME_REASSIGNMENT", username);
                               }
                              
                               public ArrayList<SmpUserNames> userNameAutocomplete(Object evt)
                               {
                               ArrayList<SmpUserNames> result = new ArrayList<SmpUserNames>();
                               String pref = (String)evt;
                               ArrayList<SmpUserNames> preCapturedusername = new SmpUserModel().fetchSmpUserNames();
                               for(int i=0; i<preCapturedusername.size(); i++)
                               {
                               if ((preCapturedusername.get(i).getStrUserNames() != null && preCapturedusername.get(i).getStrUserNames().toLowerCase().indexOf(pref.toLowerCase()) == 0) || "".equals(pref))
                               {
                               result.add(preCapturedusername.get(i));
                               }
                               }
                               return result;
                               }
                              }



                              AND my SmpRoleNames POJO class is:

                              public class SmpRoleNames
                              {
                               // Zero argument constructor
                               public SmpRoleNames()
                               {}
                              
                               // Instance variables
                               private String strRoleName;
                               private String strRoleId;
                              
                               // Constructor with arguments
                               public SmpRoleNames(String roleName)
                               {
                               this.strRoleName = roleName;
                               }
                              
                               public SmpRoleNames(String strRoleId, String roleName)
                               {
                               this.strRoleId = strRoleId;
                               this.strRoleName = roleName;
                               }
                              
                              
                               // Setter Getter methods
                               public String getStrRoleName() {
                               return strRoleName;
                               }
                              
                               public void setStrRoleName(String strRoleName) {
                               this.strRoleName = strRoleName;
                               }
                              
                               public String getStrRoleId() {
                               return strRoleId;
                               }
                              
                               public void setIRoleId(String strRoleId) {
                               this.strRoleId = strRoleId;
                               }
                              
                               @Override
                               public int hashCode() {
                               final int prime = 31;
                               int result = 1;
                               result = prime * result
                               + ((strRoleId == null) ? 0 : strRoleId.hashCode());
                               result = prime * result
                               + ((strRoleName == null) ? 0 : strRoleName.hashCode());
                               return result;
                               }
                              
                               @Override
                               public boolean equals(Object obj) {
                               if (this == obj)
                               return true;
                               if (obj == null)
                               return false;
                               if (getClass() != obj.getClass())
                               return false;
                               SmpRoleNames other = (SmpRoleNames) obj;
                               if (strRoleId == null) {
                               if (other.strRoleId != null)
                               return false;
                               } else if (!strRoleId.equals(other.strRoleId))
                               return false;
                               if (strRoleName == null) {
                               if (other.strRoleName != null)
                               return false;
                               } else if (!strRoleName.equals(other.strRoleName))
                               return false;
                               return true;
                               }
                              }


                              • 12. Re: unable to catch <h:commandButton> action event while usi
                                sumeet.singh

                                I am also using my own converter:

                                public class GenericConverter
                                implements Converter
                                {
                                 public Object getAsObject(FacesContext context, UIComponent component, String value)
                                 {
                                 System.out.println("VALUE ====> "+value);
                                 int index = value.indexOf(':');
                                 System.out.println("VALUE OBJECT ====> "+value.substring(0, index).trim()+":"+value.substring(index + 1).trim());
                                 return new SmpRoleNames(value.substring(0, index).trim(), value.substring(index + 1).trim());
                                 }
                                
                                 public String getAsString(FacesContext context, UIComponent component,Object value)
                                 {
                                 SmpRoleNames taskbean = (SmpRoleNames) value;
                                 System.out.println("VALUE IN CONVERTER ========> "+taskbean.getStrRoleId() + ":" + taskbean.getStrRoleName());
                                 return taskbean.getStrRoleId().trim()+":"+taskbean.getStrRoleName().trim();
                                 }
                                }


                                I tried a lot but still facing the same problem.

                                I checked in other forums also, some more guys are facing the same problem:

                                http://www.coderanch.com/t/453055/JSF/java/list-shuttle-exception

                                but still facing the same problem

                                • 13. Re: unable to catch <h:commandButton> action event while usi
                                  nbelaevski

                                  Try using Collection instead of List

                                  • 14. Re: unable to catch <h:commandButton> action event while usi
                                    sumeet.singh

                                    I will surely try your suggestion, but can you please explain that why you suggest Collection instead of List. Is their anything related to this error? can you please explain

                                    1 2 Previous Next