-
15. Re: unable to catch <h:commandButton> action event while usi
nbelaevski Nov 5, 2009 6:03 PM (in response to sumeet.singh)Sumeet,
Looks like I was not right, sorry. Livedemo actually uses List as data type. -
16. Re: unable to catch <h:commandButton> action event while usi
sumeet.singh Nov 6, 2009 12:15 AM (in response to sumeet.singh)Hi,
I was wondering, that if this is a component related bug, then its best that it gets reported on JIRA.
Conversely, if i am missing something then please let me know.
@Ilya, any thoughts on this? I looked up the limitation on the component in the user guide. However, that bug relates to the invocation of the listener. In my code, i am performing an action, rather an action listener. -
17. Re: unable to catch <h:commandButton> action event while usi
ilya_shaikovsky Nov 6, 2009 5:21 AM (in response to sumeet.singh)Please provide sample war with mock data and java sources to just download and run locally. Seems will be easier and faster to investigate in this way.
-
18. Re: unable to catch <h:commandButton> action event while usi
sumeet.singh Nov 6, 2009 8:10 AM (in response to sumeet.singh)Sorry, i didn't understand. I already gave all my code i.e. .jsp, bean class, converter class. What you need else???
-
19. Re: unable to catch <h:commandButton> action event while usi
nbelaevski Nov 7, 2009 11:24 AM (in response to sumeet.singh)What is bean scope?
-
20. Re: unable to catch <h:commandButton> action event while usi
sumeet.singh Nov 9, 2009 12:03 AM (in response to sumeet.singh)hi,
It's not related to bean scope: I have already checked with request and session scopes.
My bean is in request scope as of now.
I reiterate that this may be an issue with the component, as when i remove it, everything works fine.
If someone from the Richfaces team can confirm this (with the code/jsp provided above), then we can open an issue for this.
If you feel that the reason for this problem is something else, then we can discuss it here. I wish to conceptually understand the reason behind this problem.
I have tried all possibilities, and I confirm that the List Shuttle does not work for me in the scenario discussed in this thread. -
21. Re: unable to catch <h:commandButton> action event while usi
sumeet.singh Nov 11, 2009 7:09 AM (in response to sumeet.singh)please help, what should i do now?
-
22. Re: unable to catch <h:commandButton> action event while usi
nbelaevski Nov 11, 2009 9:20 AM (in response to sumeet.singh)Hi,
I've tested the code you've posted, works ok for me:package demo; import java.util.ArrayList; import java.util.List; import java.util.UUID; 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() { for (int i = 0; i < 10; i++) { this.lstCurrentRoles.add(new SmpRoleNames(UUID.randomUUID() .toString())); } for (int i = 0; i < 5; i++) { this.lstAvailableRoles.add(new SmpRoleNames(UUID.randomUUID() .toString())); } } // 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 ""; } }
<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="genericConverter" 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" /> </h:form>
package demo; import javax.faces.component.UIComponent; import javax.faces.context.FacesContext; import javax.faces.convert.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(); } }
package demo; 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; this.strRoleId = 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; } }
<converter> <converter-id>genericConverter</converter-id> <converter-class>demo.GenericConverter</converter-class> </converter> <managed-bean> <managed-bean-name>roleReAssignment</managed-bean-name> <managed-bean-class>demo.RoleReAssignment</managed-bean-class> <managed-bean-scope>session</managed-bean-scope> </managed-bean>
-
23. Re: unable to catch <h:commandButton> action event while usi
sumeet.singh Nov 12, 2009 12:00 AM (in response to sumeet.singh)hi,
Thanx. But can you please tell, whether your roleRevokeAndGrant() has been executed or not? My problem was, "when i click on the command button, i am not able to fetch the target value of listShuttle". have you tested this?? Have you find any O/P on your server console? If yes then please provide an O/P of your consolepublic String roleRevokeAndGrant() { System.out.println("HI FROM roleRevokeAndGrant ===============>"); System.out.println("CURRENTLY SELECTED ROLES ==> " + this.lstCurrentRoles); return ""; }
if it is working then please tell the version of your jboss server, richfaces jars and JSF jars... -
24. Re: unable to catch <h:commandButton> action event while usi
sumeet.singh Nov 12, 2009 12:51 AM (in response to sumeet.singh)hi nbelaevski,
Thanx for your active participation. My code is now working fine. Thanks a lot. The problem is with bean scope and hashCode and Equlas method. It means we have to implement the hashCode and equals method and the scope of the bean should be session.
It's working fine now. we can close this thread. But why it's not working with request scope. Let's take an example, if we have 50 managed bean where we use listShuttle, then have we put all of the beans in session scope? is it a good practice?? -
25. Re: unable to catch <h:commandButton> action event while usi
nbelaevski Nov 12, 2009 6:16 AM (in response to sumeet.singh)That's for security reasons. Select component does matching of submitted values against initial list of values and if it appears that they're not in the initial list, validation message appears. The same is true for any select one/many component.