1 2 Previous Next 19 Replies Latest reply on Mar 4, 2009 10:14 AM by leon850515 Go to original post
      • 15. Re: selectItems can't work with converter in h:selectOneMenu, got message "value is not valid".
        leon850515

        Hi, Orestes:


        I have removed all the intermediate code, and directly inject the session for all the database operation. the session has been configured as a seam managed hibernate session in components.xml.


        @In
        private Session wmsDatabase;


        And I change the scope to Conversation scope. And when you first enter into the profile edit page, begins a long running conversation. So it will make sure all the operation will be in the same persistence context, right?


        But it still can't work either.

        • 16. Re: selectItems can't work with converter in h:selectOneMenu, got message "value is not valid".
          leon850515

          If I use entity query for all the processors, the item 1 works, item 2 still can't work.



          <framework:hibernate-entity-query session="#{wmsDatabase}" name="processors" ejbql="select p from Processor p" />
          
          <s:selectItems value="#{processors.resultList}" var="processor" label="#{processor.name}" />




          • 17. Re: selectItems can't work with converter in h:selectOneMenu, got message "value is not valid".
            kragoth

            Ok, are you absolutely sure that the GenericObjectConverter is actually getting used?
            Put a log statement in there or something and make sure that the converter is being used.


            Second, start debugging why the getAsObject is not finding your objects in the 'cache'.


            Log out the steps that are going on in the conversion. Look at the keys that are generated etc and see if that's what's getting submitted back. Maybe something else is going on that you're not seeing.

            • 18. Re: selectItems can't work with converter in h:selectOneMenu, got message "value is not valid".
              leon850515

              Yes, I'm pretty sure the GenericObjectConverter is used on the processor entity. The log shows all the processor has been put in the ObjectConverterStore. Plus the getAsObject can found objects in the 'cache'. I can see the info in the log too.


              Actually, your code works only if I remove the overridden method equals and hashCode.


              The Processor has extends form BaseModel, there defined the two methods:



                   public boolean equals(Object o) {
                        if (this == o) {
                             return true;
                        }
                        if (o == null || !(o.getClass() == this.getClass())) {
                             return false;
                        }
              
                        BaseModel other = (BaseModel) o;
              
                        // if the id is missing, return false
                        if (getId() == null) {
                             return false;
                        }
              
                        // equivalence by id
                        return getId().equals(other.getId());
                   }
              
                   public int hashCode() {
                        if (getId() != null) {
                             return getId().hashCode();
                        } else {
                             return super.hashCode();
                        }
                   }




              • 19. Re: selectItems can't work with converter in h:selectOneMenu, got message "value is not valid".
                leon850515

                Hi,Orestes and Ingo:


                I made below change, it works.


                1.Change the scope to Conversation scope and begins a long-running conversation when enter into the profile edit page. So it will make sure load the entities for the selectOneMenu with the same persistence context that you are using in the converter.


                2.Remove the overridden equals and hashCode method. The method implementation is on the above comment. Why should I remove these two methods?


                 

                1 2 Previous Next