3 Replies Latest reply on Nov 18, 2009 6:46 PM by notify

    h:selectOneMenu - argument type mismatch

    notify
      I'm using Seam 2.2.0.GA

      <h:outputLabel for="userTitles">Title</h:outputLabel>
           <h:selectOneMenu value="#{userTitles}" required="true" id="userTitles" >
                <s:selectItems value="#{userTitlesList}" var="userTitles" label="#{userTitles.title}" noSelectionLabel="Please select"/>
                <s:convertEntity/>
           </h:selectOneMenu>

      The above code works, except it always display the last title in the list retrieved from the table. i.e. in the table I have Mr. Mrs. Ms. Dr. and "Dr." will always be displayed. The title I select and save is passed back to the EJB and persisted to the table fine.

      If I change the code to;

      '
      <h:outputLabel for="userTitles">Title</h:outputLabel>
           <h:selectOneMenu value="#{userTitles.title}" required="true" id="userTitles" >
                <s:selectItems value="#{userTitlesList}" var="userTitles" label="#{userTitles.title}" noSelectionLabel="Please select"/>
                <s:convertEntity/>
           </h:selectOneMenu> '

      '
      I get the "Please select" displayed, which is what I want with the other titles in the list. However when I save it and I return to the page I get;

      /register.xhtml @63,84 value="#{userTitles.title}": java.lang.IllegalArgumentException: argument type mismatch

      In the JBoss (4.2.3.GA) Console I get;

      10:32:45,172 ERROR [STDERR] 13-Nov-2009 10:32:45 javax.faces.component.UIInput updateModel
      SEVERE: /register.xhtml @63,84 value="#{userTitles.title}": java.lang.IllegalArgumentException: argument type mismatch
      java.lang.IllegalArgumentException: argument type mismatch

      I've Googled till the cows come home and can't find (or understand) a definitive answer on how to resolve it.

      title is a String and all problems seem to be conversion from dates and numbers.

      Thanks.
        • 1. Re: h:selectOneMenu - argument type mismatch
          notify
          If I remove the converter;

          <s:convertEntity/>

          I get the entity 'name' not the value passed to my EJB and persisted to the table;

          com.notifypinpoint.entity.UserTitles@794a09

          Is there a problem with <s:convertEntity/> ?

          • 2. Re: h:selectOneMenu - argument type mismatch
            notify
            Getting nowhere with;

            <s:convertEntity/>

            So I wrote custom converter.

            The list now displays as expected and the converter pulls off the correct value selected from the list. However when it is returned to the XHTML page I get the error message;

            “value is not valid” display on the page.

            I solved this before my overwriting the equals method in the Entity Bean with a return true, this time it doesn’t help. I also tried the other suggestion from;

            http://seamframework.org/Community/EntityConverterValueIsNotValid

            I only have one Persistence Context in my components.xml

            When I put a debug statement in the equals method it appears not to be calling it!
            Been on this for four days now and getting no where, any suggestions please.

            • 3. Re: h:selectOneMenu - argument type mismatch
              notify