14 Replies Latest reply on Oct 28, 2008 4:40 PM by nimo22

    rich:listShuttle: validation error: shuttle has invalid valu

    opr

      I am using JSF 1.2.0 and Rich Faces 3.2.0 on Tomcat 6

      My jsp-Page contains a listShuttle control which is populated by hibernate entities

      <rich:listShuttle
       binding="#{customerBean.shuttle}"
       orderControlsVisible="false"
       fastOrderControlsVisible="false"
       fastMoveControlsVisible="false"
       moveControlsVisible="true"
       copyControlLabel="#{i18n.masterdata_customer_lbAdd}"
       removeControlLabel="#{i18n.masterdata_customer_lbDelete}"
       sourceCaptionLabel="#{i18n.masterdata_customer_lbAllVendors}"
       targetCaptionLabel="#{i18n.masterdata_customer_lbOneTier}"
       id="shuttle"
      
       sourceValue="#{customerBean.vendorSourceItems}"
       targetValue="#{customerBean.vendorTargetItems}"
      
       var="vendor"
       listsHeight="200"
       converter="shuttleVendorConverter">
      
       <rich:column sortable="false">
       <h:outputText value="#{vendor.name}"></h:outputText>
       </rich:column>
      </rich:listShuttle>
      
      


      In my backing bean source and value items are defined as


      private List<Vendor> vendorSourceItems;
      private List<Vendor> vendorTargetItems;
      


      with getter and setter-Methods.

      The shuttle is populated by an action method.

      When submitting the form I get a validation error which says:


      Component customer:shuttle has invalid value expression com.gft.rfs.hibernate.Vendor@930120


      The converter works correctly. I tried to wrap the hibernate classes, but nothing changed.

      I tried nearly everything without success. What might be wrong?

        • 1. Re: rich:listShuttle: validation error: shuttle has invalid
          nbelaevski

          Hello,

          That can be if equals()/hashCode() methods aren't implemented for the entities in the right way

          • 2. Re: rich:listShuttle: validation error: shuttle has invalid
            opr

            Hello,

            i tried it in the following way:

            package com.gft.rfs.hibernate;
            
            // Generated 02.04.2008 10:02:43 by Hibernate Tools 3.2.0.CR1
            
            import java.util.HashSet;
            import java.util.Set;
            
            /**
             * Vendor generated by hbm2java
             */
            public class Vendor implements java.io.Serializable {
            
             private int id;
             private Address addressByInvoiceAddress;
             private Contact contact;
             private Address addressByAddress;
             private String name;
             private String insignGroupname;
             private Set<Pmvalue> pmvalues = new HashSet<Pmvalue>(0);
             private Set<Request> requests = new HashSet<Request>(0);
             private Set<Candidate> candidates = new HashSet<Candidate>(0);
             private Set<Activity> activities = new HashSet<Activity>(0);
             private Set<Employee> employees = new HashSet<Employee>(0);
             private Set<Consultant> consultants = new HashSet<Consultant>(0);
             private Set<Customer> customers = new HashSet<Customer>(0);
            
             public Vendor() {
             }
            
             public boolean equals(Object o)
             {
             if (! (o instanceof Vendor))
             return false;
             else
             if (this.getId() != ((Vendor)o).getId())
             return false;
            
             return true;
             }
            
             public int hashCode()
             {
             return this.getId();
             }
            .....
            
            


            No effect. Any other ideas?

            • 3. Re: rich:listShuttle: validation error: shuttle has invalid
              nbelaevski

              That can also happen if newly submitted items aren't present neither in source nor in target value.

              Please check if the item causing the problem:

              com.gft.rfs.hibernate.Vendor@930120
              exists in any of the values

              • 4. Re: rich:listShuttle: validation error: shuttle has invalid
                nimo22

                hello,

                I get also the error:

                :listShuttle has invalid value expression com.entity.Person@930120


                I have a Map to hold the data of sourceList and targetList:
                Map<String, List<Person>> = new HashMap<String, List<Person>>();


                In my Person-Entity, I have overridden equals/hashCode-Method. (Should I do it somewhere else? For the String-keys????)

                The strange thing is,
                that at first all works,
                but after I pick one item from one side to the other and this many times, then sporadically the error "has invalid value expression" occurs,
                and the item which produced the failure, is no more in my (target/source-)list.

                Any Ideas??

                • 5. Re: rich:listShuttle: validation error: shuttle has invalid
                  ilya_shaikovsky

                  look to Nick's suggestion. Non valid message will not appears if you converter and equals/hasCode methods doesn't contains errors.

                  • 6. Re: rich:listShuttle: validation error: shuttle has invalid
                    nimo22

                    hello ilya,

                    my Converter is not the reason (I use seam.entityConverter and this works well).

                    My hashCode/equals-Method...this can be the reason..but I do not find the problem. I use this hashCode/equals-Method in my entityBean (with JPA/Hibernate) all the time and it makes no problem:


                    @Entity
                    public class Person implements Serializable{
                    
                    @Id
                    Integer idPerson;
                    
                    String name;
                    
                    String age;
                    
                    //getter/setter
                    ...
                    @Override
                     public boolean equals(Object o) {
                    
                    if (this == o) return true;
                    
                    if (o == null || getClass() != o.getClass()) return false;
                    
                    Person that = (Person) o;
                    
                    if (idPerson != null ? !idPerson .equals(that.idPerson ) : that.idPerson != null) return false;
                    if (name!= null ? !name.equals(that.name) : that.name!= null) return false;
                    if (age!= null ? !age.equals(that.age) : that.age!= null) return false;
                    
                    return true;
                     }
                    
                    
                    @Override
                    public int hashCode() {
                    
                    int result = 1;
                    result = 31* result + ((idPerson == null) ? 0 : idPerson .hashCode());
                    result = 31* result + ((name== null) ? 0 : name.hashCode());
                    result = 31* result + ((age== null) ? 0 : age.hashCode());
                    
                    return result;
                    }
                    
                    }


                    You see, my entityBean is well implemented (or is my equals/hashCode-Method faulty????)


                    The list of my targetValue and sourceValue is a ArrayList:
                    List<Person> source= new ArrayList<Person>();
                    List<Person> target = new ArrayList<Person>();


                    and all works, but sometimes I get this failure:

                    :listShuttle has invalid value expression com.entity.Person@930120


                    I have also another problem with my listShuttle:
                    I get this exception, when putting values from the source to the target -list:

                    java.lang.IllegalArgumentException: Cannot convert [com.entity.Person@f459998c] of type class java.util.ArrayList to interface java.util.Set


                    Should I use a Set instead of a ArrayList for my target/sourceValue??? Is this the problem for all? Because a Set cannot contain duplicate hashkeys, maybe this is the problem for

                    :listShuttle has invalid value expression com.entity.Person@930120


                    Could you help me out, please?


                    • 7. Re: rich:listShuttle: validation error: shuttle has invalid
                      ilya_shaikovsky

                      seems you do not need to change your list to set. but you hashCode should not be the same for different items.

                      • 8. Re: rich:listShuttle: validation error: shuttle has invalid
                        nimo22

                        okay, I do not change my collection-type from ArrayList to HashSet..so why this message occurs?

                        java.lang.IllegalArgumentException: Cannot convert [com.entity.Person@f459998c] of type class java.u
                        til.ArrayList to interface java.util.Set


                        My hashCode/equals-Method is well, isnt it? I guess, it s well.

                        I have printed out my hashCodes for my object when a item is picked from source-box to target-box and it seems the hashCodes are different:

                        ...
                        17:59:40,328 INFO [STDOUT] hashCode Person: ted 575829025
                        17:59:40,328 INFO [STDOUT] hashCode Person: john1335323059
                        17:59:40,328 INFO [STDOUT] hashCode Person: eddi1335323059
                        ...


                        So why this message comes:
                        :listShuttle has invalid value expression com.entity.Person@930120


                        Should I overwrite the key-value of my map?

                        I have a Map for holding my data of the source-list:

                        Map<String, List> myTargetList = new HashMap<String, List>();

                        I have a overwritten equals/hashCode-Method for my Person-Entity, but I have NO overwritten equals/hashCode for the String-Value!! SHOULD I?

                        I guess, it a collision in my hashMap..I have no clue!

                        • 9. Re: rich:listShuttle: validation error: shuttle has invalid
                          nimo22

                          sorry...I have typed false. This is my map:

                          Map< String , List> myTargetList = new HashMap<String, List>();

                          Do I need overwrite equals/hashCode for my String-Key??

                          • 10. Re: rich:listShuttle: validation error: shuttle has invalid
                            nimo22

                            sorry...I have typed false. This is my map:

                            Map< String , List> myTargetList = new HashMap<String, List>();


                            Do I need overwrite equals/hashCode for my String -Key??

                            • 11. Re: rich:listShuttle: validation error: shuttle has invalid
                              nimo22

                               

                              Map< String , List<Person>> myTargetList = new HashMap<String, List<Person>>();


                              Do I need overwrite equals/hashCode for my String -Key??

                              • 12. Re: rich:listShuttle: validation error: shuttle has invalid
                                nimo22

                                such a failure occurs, which comes sporadically, when I often pick one item from one box to the other:

                                [STDOUT] AfterPhase: APPLY_REQUEST_VALUES 2
                                [STDOUT] BeforePhase: RENDER_RESPONSE 6
                                INFO [STDOUT] HashCode Person Ted 1410926781
                                INFO [STDOUT] HashCode Person Eddi 575829025
                                INFO [STDOUT] HashCode Person Eve -1335323059
                                INFO [STDOUT] HashCode Person Sam 1596999837
                                INFO [STDOUT] HashCode Person Ted 1410926781
                                INFO [STDOUT] HashCode Person Eddi 575829025
                                INFO [STDOUT] HashCode Person Eve -1335323059
                                INFO [STDOUT] HashCode Person User 1596999837
                                INFO [STDOUT] HashCode Person Ted 1410926781
                                INFO [STDOUT] HashCode Person Eddi 575829025
                                INFO [STDOUT] HashCode Person Eve -1335323059
                                INFO [STDOUT] HashCode Person User 1596999837
                                INFO [STDOUT] HashCode Person Eddi 576782338
                                INFO [STDOUT] HashCode Person Rolf-582658566
                                INFO [STDOUT] HashCode Person Rolf-582658566
                                INFO [STDOUT] HashCode Person Rolf-582658566
                                INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
                                sourceId=myView:j_id200[severity=(ERROR 2), summary=("Component myView:j_id200 has invalid value expression myEntity.Person@541908bd"), detail=("Component myView:j_id200 has invalid value expression myEntity.Person@541908bd")]
                                 sourceId=myView:j_id58[severity=(ERROR 2), summary=("Component myView:j_id58 has invalid value expression myEntity.Person@541908bd"), detail=("Component myView:j_id58 has invalid value expression myEntity.Person@541908bd")]
                                 sourceId=myView:j_id129[severity=(ERROR 2), summary=("Component myView:j_id129 has invalid value expression myEntity.Person@541908bd"), detail=("Component myView:j_id129 has invalid value expression myEntity.Person@541908bd")]
                                 18:24:39,187 INFO [STDOUT] AfterPhase: RENDER_RESPONSE 6



                                The hashCodes seems different for every entity-object, or? What should I do more? I have a converter which works, a entity, which works, a hashSet which works, and a listShuttle which sporadically not work!

                                What would you do? What is wrong?

                                • 13. Re: rich:listShuttle: validation error: shuttle has invalid
                                  nbelaevski

                                  Hmm, that's Ted who's missing.

                                  Do you modify set of items contained in sum in source and target value collections without updating view on the client?

                                  What implementation of lists is used? How about example project - you can send it to me to nbelaevski at exadel dot com?

                                  • 14. Re: rich:listShuttle: validation error: shuttle has invalid
                                    nimo22

                                    Hello Nick,

                                    sorry for posting so late..thank you for your hint :

                                    Do you modify set of items contained in sum in source and target value collections without updating view on the client


                                    Exactly this was the reason for the message "has invalid value expression".

                                    I have used a method by onlistchanged-event and this method modified items from one box - this method was faulty.

                                    Now the listShuttle works well !!

                                    thanks!!