10 Replies Latest reply on Sep 26, 2007 10:13 AM by pmuir

    Entity Convert

    nusseis

      Hi all,

      I'm working with seam and jboss since a few weeks. Now I'm trying to fill a selectOneMenu with an object using <s:convertEntity />

      The problem is, I want to submit that form containing the selectOneMenu and save it in the database. As I click on the submit button the jboss server does something, and I mean something!
      It doesn't write an error message or anything else, the only response I got is from the <h:messages showDetail="true" /> component.

      I only got the german message but it's something like:
      "Validation error _id35: Value is no valid selection"

      Would be cool, if anyone could help me. I'm trying to fix this problem since a few days and it's becoming frustrating now.

      Thanks, Kim

        • 1. Re: Entity Convert
          pmuir
          • 2. Re: Entity Convert
            amitev

            Are you using SMPC?

            • 3. Re: Entity Convert
              nusseis

              @pete: thanks buddy, you're making my day, that works!

              @amitev: no, I don't...at least I think I don't :)

              • 4. Re: Entity Convert
                nusseis

                Well, I'm back...

                Ain't got problems with the selectOneMenu, but with the selectManyMenu and I don't know why. Hoping for help, so here's what I've got:

                I've implemented the equals and hashCode Method in all of my entity beans

                @Override
                 public boolean equals(Object obj) {
                 if (!(obj instanceof Platform)) {
                 return false;
                 }
                
                 Platform o = (Platform) obj;
                 return this.platform_id == o.getPlatform_id();
                 }
                
                 @Override
                 public int hashCode() {
                 int result = 17;
                
                 result = 37 * result + this.platform_id;
                
                 return result;
                 }


                And that works fine with the selectOneMenu, no errors or warnings. Now I've got a selectManyMenu, that looks like this:

                <h:selectManyMenu value="#{release.platform_id}" id="selectPlatformList" size="10">
                 <s:selectItems value="#{admin_release.ra_platformList}" var="p" label="#{p.platform_descr}" />
                 <s:convertEntity />
                 </h:selectManyMenu>


                Now the question: Why do I get the "Value is not a valid option" message?

                • 5. Re: Entity Convert

                  You have to specify the entity class on the convertentity tag. It can not automatically detect the entity class of a collection.

                  Regards

                  Felix

                  • 6. Re: Entity Convert
                    nusseis

                    That sounds got, thanks!

                    Could you tell me how the specify the class? I can't find anything in the seam docu or on google...

                    • 7. Re: Entity Convert

                      Hi there..

                      I have a very similar problem. In fact I am fighting with it for weeks now, postponing its solution over and over...I don't know when it happened the first time, but it arose out of the blue.
                      I am using Seam 1.2.1GA on JBoss 4.0.5GA with Facelets, Ajax4JSF, seam managed persisten context, and JSF 1.2 RI.
                      It's the User entity, a select many dropdown will give me random invalid values for the select items in it. Say, there are 10 values in that list, all are shown, then the first, the 3rd and maybe the fifth will be accepted all others receive a "value is not valid". On the same page I am using the selectItems with another entity type (Customer) with no problem at all. Further I am deriving my entities all from a DbItem super class which ensures ID equality and such...
                      I tried nearly everything imaginable. Changed the entity name, refactored the class name, copied the entityConverter and overrode it with my more verbose implementation. I really have no idea why this happens only for this particular entity. I was even migrating to Seam-2CR1 tested it shortly and noticed the same problem, but with a minor difference: after trying to apply the values, i.e. submitting the form, the rerendered paged showed empty labels in the dropdown, with all values set to ??.noSelectionValue???...

                      Does this sound familiar to anybody? Or is there anybody out there having an idea for a possible solution?
                      Pete?

                      thanks,
                      Tino

                      The XHTML piece:

                       <h:selectOneMenu value="#{query.example.cataloguer}" id="item_cataloguer">
                       <s:selectItems value="#{allUserList.resultList}" var="user" label="#{user.stringRep}"/>
                       <s:convertEntity/>
                       </h:selectOneMenu>
                      


                      • 8. Re: Entity Convert
                        pmuir

                        You should try upgrading to Seam2 - the entity converter is significantly different.

                        • 9. Re: Entity Convert

                          @ffh: The tag convertEntity doesn't have any attributes. And as far as I can see, the EntityConverter is intelligent enough to recognize classes.

                          Perhaps the problem is not the EntityConverter but the implementation of h:selectManyMenu? Since nusseis doesn't have problems with selectOneMenu.

                          @Peter: I got the same advice from you. But I think that updating to Seam2 is only imaginable when Seam2 is released. I read a few times about this "selection is invalid" problem. Maybe they are all caused by the same little bug. Would be nice if this could be fixed.

                          • 10. Re: Entity Convert
                            pmuir

                            There are currently no plans for 1.2.2.GA release.