1 2 Previous Next 23 Replies Latest reply on Jan 27, 2012 9:25 AM by giddasriram Go to original post
      • 15. Re: List Shuttle Validation Error
        thetikigod.tiki_god.mail.com

        Ive started a different project to test to see if I can get this working from a fresh standpoint.  Instead of using bijection I used extended EL to pass the information around.  it seems to work this way as I am not getting the validation errors, and I also have a totally separate class that manages the shuttle.  Everything seems to be working properly.  I am using the same database in the new project.  The entites used are basically copied and pasted (ie the same and no validation).  Any ideas what is going on here? 

        • 16. Re: List Shuttle Validation Error
          thetikigod.tiki_god.mail.com

          So here is the code that currently works, however, Id like the user and its specific roles to be managed by the same action.  I would also like to stay away from using extended EL.  I am not sure why this works over the other implementation where the ListShuttle is in the modal panel instead of directly in the users table (did it that way for quick and easy way to see if I can get it to work).  This is really driving me nuts!




                                 <h:form>
                                  <rich:dataTable id="usersTable" value="#{users}" var="u" rows="10">
                                       <f:facet name="header">
                                        <rich:datascroller id="userTableScroller1" for="usersTable" ajaxSingle="false" reRender="userTableScroller2" />
                                    </f:facet>
                                    
                                       <rich:column>
                                            <f:facet name="header"><h:outputText value="User ID" /></f:facet>
                                            <h:outputText value="#{u.userId}" />
                                       </rich:column>
                                       
                                       <rich:column>
                                            <f:facet name="header"><h:outputText value="Last Name" /></f:facet>
                                            <h:outputText value="#{u.lastName}" />
                                       </rich:column>
                                       
                                       <rich:column>
                                            <f:facet name="header"><h:outputText value="First Name" /></f:facet>
                                            <h:outputText value="#{u.firstName}" />
                                       </rich:column>
                                       
                                       <rich:column>
                                            <f:facet name="header"><h:outputText value="Phone" /></f:facet>
                                            <h:outputText value="#{u.phone}" />
                                       </rich:column>
                                       
                                       <rich:column>
                                            <f:facet name="header"><h:outputText value="Email" /></f:facet>
                                            <h:outputText value="#{u.email}" />
                                       </rich:column>
                                       
                                       <rich:column>
                                            <f:facet name="header"><h:outputText value="Actions" /></f:facet>
          
                                             <h:form>
                                            <rich:listShuttle id="userShuttle" sourceValue="#{userrolemanager.getUnassignedRoles(u)}" targetValue="#{u.roles}" var="r" converter="roleConverter" fastOrderControlsVisible="false" orderControlsVisible="false">
                                                  <h:column>
                                                       <h:outputText value="#{r.roleId}" />
                                                  </h:column>
                                             </rich:listShuttle>
                                             <h:commandButton value="Save" action="#{usermanager.save(u)}" />
                                             </h:form>
                                       </rich:column>
                                       
                                       <f:facet name="footer">
                                        <rich:datascroller id="userTableScroller2" for="usersTable" ajaxSingle="false" reRender="userTableScroller1" />
                                    </f:facet>
                                  </rich:dataTable>
                             </h:form>



          Any ideas anyone?

          • 17. Re: List Shuttle Validation Error
            thetikigod.tiki_god.mail.com
            • 18. Re: List Shuttle Validation Error
              gjeudy

              Downgrading to 3.2.1.GA could help? I'm using listShuttle all over the place and I use richfaces 3.2.1.GA.


              Let me know,

              • 19. Re: List Shuttle Validation Error
                thetikigod.tiki_god.mail.com

                No dice so far.still getting validation errors.


                When I remove the sourceValue attribute from the list shuttle, I am able to save changes to the user without validation errors.  Could it be possible that some value is somehow sneaking in that the converters dont like?


                Original:


                <rich:listShuttle sourceValue="unassignedRoles" targetValue="#{user.roles}" var="role">
                     <s:convertEntity />
                     <h:column>
                          <h:outputText value="#{role.roleId}" />
                     </h:column>
                </rich:listShuttle>




                heres the code that is pertinent to the unassignedRoles


                     @Out( required = false )
                     private List<Role> unassignedRoles;
                
                     @Begin
                     public String init() {
                
                          unassignedRoles = em.createQuery( "select r from Role r" ).getResultList();
                          unassignedRoles.removeAll( this.user.getRoles() );
                          
                          return null;
                     }
                
                     @End
                     public String edit() {
                
                          this.em.merge( this.user );
                          this.find();
                          this.user = null;
                
                          return null;
                     }



                unassigned roles also has the appropriate getters and setters and are included in the interface class.


                Could I be comparing two different things?  I use a query to get all the roles, and remove the ones the user has.  I then use that unassignedRoles variable as the source and I use user.roles directly from the user object as the target.  Is there anything wrong with this setup?  Is there a better way to setup the backing bean than what I am currently doing?


                • 20. Re: List Shuttle Validation Error
                  thetikigod.tiki_god.mail.com

                  Would someone be able to post a working example for me?  I really think it has something to do with how im getting my lists.

                  • 21. Re: List Shuttle Validation Error
                    didudeb2007
                    I have completed this ListShuttle thing after a long research. Now Its working fine for me.

                    I am posting my codes which will be helpful to you all.


                    XHTML     
                    ============
                    <ui:define name="body">

                            <h:form id="myForm">
                            <rich:messages>
                                    <f:facet name="errorMarker">
                                            <h:graphicImage value="/images/ajax/error.gif" />  
                                    </f:facet>
                            </rich:messages>
                            <h:inputText value="#{componentAction.browseEditVar}" />
                            <rich:listShuttle id="myListShuttle" sourceValue="#{componentAction.freeItemsList}" targetValue="#{componentAction.itemsList}" 
                                  sourceRequired = "true" targetRequired = "true" var="items"
                                  sourceCaptionLabel="Source List" targetCaptionLabel="Target List" converter="listShuttleCoverter">
                                <rich:column>
                                        <h:outputText value="#{items.label}" />
                                </rich:column>
                        
                            </rich:listShuttle>
                            <h:commandButton value="Submit" action="#{componentAction.browseEditComponents}"/>
                           
                          </h:form>
                         
                         
                          <rich:dataTable value="#{componentAction.freeItemsList}" var="obj1" headerClass="dataTblCustom " style="background-color:#FFFFFF;border:1px solid #AAAAAA;">
                              <rich:column styleClass="alignRight" width="17%">
                                <f:facet name="header">ID</f:facet>
                              <h:outputText value="#{obj1.id}" />
                              </rich:column>
                              <rich:column width="16%">
                                <f:facet name="header">LABEL</f:facet>
                                <h:outputText value="#{obj1.label}" />
                              </rich:column>
                           </rich:dataTable>
                          
                           <rich:dataTable value="#{componentAction.itemsList}" var="obj2" headerClass="dataTblCustom " style="background-color:#FFFFFF;border:1px solid #AAAAAA;">
                              <rich:column styleClass="alignRight" width="17%">
                                <f:facet name="header">ID</f:facet>
                              <h:outputText value="#{obj2.id}" />
                              </rich:column>
                              <rich:column width="16%">
                                <f:facet name="header">LABEL</f:facet>
                                <h:outputText value="#{obj2.label}" />
                              </rich:column>
                           </rich:dataTable>

                        </ui:define>










                    CONVERTER
                    =========
                    @Stateless
                    @Name( "listShuttleCoverter" )
                    @org.jboss.seam.annotations.faces.Converter    
                    public class ListShuttleCoverter implements Converter {
                           
                            public Object getAsObject(FacesContext context, UIComponent component,String value) {  
                                int index = value.indexOf(':');   System.out.println("Inside getAsObject");
                                return new FreeItems(value.substring(0, index), value.substring(index + 1));  
                            }  
                         
                            public String getAsString(FacesContext context, UIComponent component,Object value) {  
                                 FreeItems freeItems = (FreeItems) value;    System.out.println("Inside getAsString");
                                return freeItems.getId() + ":" + freeItems.getLabel();  
                            } 

                    }



                    ENTITY
                    ==========

                    @Entity
                    @Name( "freeItems" )
                    public class FreeItems implements Serializable {
                         
                         private static final long serialVersionUID = -4986478572805938755L;
                         String id;
                         String label;

                         public FreeItems(String id, String label) {
                              super();
                              this.id = id;
                              this.label = label;
                         }

                         @Id
                        @Column(name = "USER_ID")
                         public String getId() {
                              return id;
                         }
                         public void setId(String id) {
                              this.id = id;
                         }
                         @Column(name = "LABEL")
                         public String getLabel() {
                              return label;
                         }
                         public void setLabel(String label) {
                              this.label = label;
                         }
                         
                         @Override
                         public int hashCode() {

                              final int prime = 31;
                              int result = 1;
                              result = prime * result + ((id == null) ? 0 : id.hashCode());
                              result = prime * result + ((label == null) ? 0 : label.hashCode());
                              return result;
                         }

                         @Override
                         public boolean equals( Object obj ) {
                            if (this == obj)
                              {
                                   System.out.println( "[TRUE] Addresses are the same." );
                                   return true;
                              }
                              if (obj == null) {
                                   System.out.println( "[FALSE] Obj is null." );
                                   return false;
                              }
                              if (getClass() != obj.getClass()) {
                                   System.out.println( "[FALSE] Classes arent the same." );
                                   return false;
                              }
                              final FreeItems other = (FreeItems) obj;
                              
                              if (id == null) {
                                   if (other.id != null) {
                                        System.out.println( "[FALSE] id on other is null." );
                                        return false;
                                   }
                              }
                              else if (!id.equals( other.id )) {
                                   System.out.println( "[FALSE] RoleIds not equal." );
                                   return false;
                              }
                              if (label == null) {
                                   if (other.label != null) {
                                        System.out.println( "[FALSE] RoleId on other is null." );
                                        return false;
                                   }
                              }
                              else if (!label.equals( other.label )) {
                                   System.out.println( "[FALSE] RoleIds not equal." );
                                   return false;
                              }
                            System.out.println( "[TRUE] Passed all tests." );
                              return true;
                         }
                    }



                    ACTION
                    ======

                    @Name("componentAction")
                    @Scope(ScopeType.SESSION)
                    public class ComponentAction{
                    private List<FreeItems> freeItemsList = new ArrayList<FreeItems>();
                       
                        private List<FreeItems> itemsList =new ArrayList<FreeItems>();
                       
                       
                         
                         
                         
                         
                         public List<FreeItems> getFreeItemsList() {
                              return freeItemsList;
                         }

                         
                         public void setFreeItemsList(List<FreeItems> freeItemsList) {
                              this.freeItemsList = freeItemsList;
                         }

                         public List<FreeItems> getItemsList() {
                              return itemsList;
                         }

                         public void setItemsList(List<FreeItems> itemsList) {
                              this.itemsList = itemsList;
                         }


                    public ComponentAction() {
                             //############################################
                             FreeItems obj1 = new FreeItems("1", "Open");
                             FreeItems obj2 = new FreeItems("2", "Save");
                             FreeItems obj3 = new FreeItems("3", "SaveAll");
                             FreeItems obj4 = new FreeItems("4", "Delete");
                             freeItemsList.add(obj1);
                             freeItemsList.add(obj2);
                             freeItemsList.add(obj3);
                             freeItemsList.add(obj4);
                             
                             FreeItems itm1 = new FreeItems("5", "Create Folder");
                             FreeItems itm2 = new FreeItems("6", "Create Doc");
                             FreeItems itm3 = new FreeItems("7", "Find");
                             itemsList.add(itm1);
                             itemsList.add(itm2);
                             itemsList.add(itm3);
                             //############################################
                    }

                    }
                    • 22. Re: List Shuttle Validation Error
                      didudeb2007

                      If any problem, reply me back.


                      --
                      Debasis

                      • 23. Re: List Shuttle Validation Error
                        giddasriram

                        Hi Debasis
                                 I am also using rich listshuttle in seam framework I am using List of Strings as source and target values and this is throwing same component as you mentioned above. Here is something what would my actual code looks like.




                        <rich:listShuttle sourceValue="#{myBean.AvailableArray}"
                                                                                                id="myId" sourceCaptionLabel="AvailableArray" targetCaptionLabel="TotalSelectedArray" 
                                                                                                targetValue="#{myBean.totalSelectedArray}" var="items" 
                                                                                                listsHeight="170" sourceListWidth="150" targetListWidth="150"
                                                                                    
                        
                        
                        
                                    fastMoveControlsVisible="false" fastOrderControlsVisible="false" >
                                                                                        <rich:column>
                                                                                                <t:outputText value="#{items}" />
                                                                                        </rich:column>                                                                                                                                                                            
                                                                <a4j:support id="a4jSuppBtn" event="onlistchanged" actionListener="#{myAction.copySelectedArray}" reRender="myIdTwo" process="myIdTwo"/>
                                                                </rich:listShuttle>
                                                                
                                                                <rich:listShuttle sourceValue="#{myBean.selectedArray}"
                                                                                                id="myIdTwo" sourceCaptionLabel="SelectedArray" targetCaptionLabel="DefaultArray" 
                                                                                                targetValue="#{myBean.defaultFieldsArray}" var="etems" 
                                                                                                listsHeight="170" sourceListWidth="150" targetListWidth="150" 
                                                                                                fastMoveControlsVisible="false" fastOrderControlsVisible="false">
                                                                                        <h:column>
                                                                                                <h:outputText value="#{etems}" />
                                                                                        </h:column>
                                                                                        <a4j:support id="a4jSuppBtnTwo" event="onlistchanged" actionListener="#{myAction.copySelectedArray}"  reRender="myIdTwo" process="myIdTwo"/>                                                                                                                                                                              
                                                                </rich:listShuttle>





                        I am rerendering the second listshuttle with the first copy or remove. Could you please point me where I am doing wrong

                        1 2 Previous Next