7 Replies Latest reply on May 20, 2008 12:26 PM by Pete Muir

    s:selectItems's itemValue usage

    Branimir Minkov Newbie

      I am trying to set a String value on a backing bean.
      Here is the Facelet part:


      <h:selectOneMenu value="#{someEntity.someString}">
      
         <s:selectItems value="#{someEjbQl.resultList}" var="obj" label="#{obj.name}" itemValue="#{obj.code}" noSelectionLabel="Please select..." />
      
         <s:convertEntity />
      
      </h:selectOneMenu>



      The issue is that I want to have a String submitted and set by Seam, in {someEntity.someString}. I think that the usage of itemValue controls of what gets submitted to the server. What happens is that in practice is different. When using it with s:convertEntity it tries to set similar to this package-path.ObjectClass@100a7, when I do not use the s:convertEntity it tries to set the primary key of the object to the backing String property. I believe I am doing something wrong but could not find a solution in the forum so far. Thanks in advance.

        • 1. Re: s:selectItems's itemValue usage
          Pete Muir Master

          Don't use <s:convertEntity />, without it, JSF should try to set the value to #{obj.code} - check the generated HTML and see what the output value for each <option /> is.


          Please make an effort when posting to format your post and check the preview before posting (I fixed it this time).

          • 2. Re: s:selectItems's itemValue usage
            Emmanuel Charpentier Newbie

            Branimir Minkov wrote on Apr 07, 2008 10:42 AM:


            <h:selectOneMenu value="#{someEntity.someString}">
               <s:selectItems value="#{someEjbQl.resultList}" var="obj" label="#{obj.name}" itemValue="#{obj.code}" noSelectionLabel="Please select..." />
            </h:selectOneMenu>




            It does seem like itemValue is currently broken :(

            • 3. Re: s:selectItems's itemValue usage
              Pete Muir Master

              Please report in JIRA along with reproduction steps or better yet a patch for the ui example to show the problem.


              Thanks!

              • 4. Re: s:selectItems's itemValue usage
                Branimir Minkov Newbie

                Cleared browser and JBoss 4.2.1's cache. Here is the HTML output when removing the <s:convertEntity />:


                <select name="editRelationForm:j_id143" size="1">     
                     <option value="org.jboss.seam.ui.NoSelectionConverter.noSelectionValue">Please select...</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@100a7">ARC</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@10115">AUT</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@10266">BAP</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@1077b">CLO</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@12ff5">NEW</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@136fd">PAY</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@138f8">PRE</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@138fd">PRJ</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@1397b">PVL</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@139da">PYN</option>
                     <option value="com.phpstruts.domain.IstsRfIstsRf@13eec">REJ</option>
                </select>


                • 5. Re: s:selectItems's itemValue usage
                  Branimir Minkov Newbie

                  <s:selectItems ... /> is a very cool feature that is a winner, on top of its <f:selectItems ... /> JSF brother. Making the 'itemValue' fixed will make this component without any competition.

                  • 6. Re: s:selectItems's itemValue usage
                    Matthias Gladt Newbie

                    Hi,


                    I have


                    public class DateSelectItem {
                    
                         private String label = null; // getter,setter
                         private Date value = null;// getter,setter
                    }
                    


                    and


                    <h:selectOneMenu value="#{component.someDate}">
                        <s:selectItems value="#{component.dateSelectItemList}" var="item"
                            label="#{item.label}" itemValue="#{item.value}" />
                        <a4j:support event="onchange" ajaxSingle="true" />
                    </h:selectOneMenu>
                    


                    with Seam 2.0.2 and get



                    sourceId=j_id16:j_id20[severity=(ERROR 2), summary=(Conversion Error setting value 'Thu Jan 01 11:00:00 CET 1970' for 'null Converter'. ), detail=(Conversion Error setting value 'Thu Jan 01 11:00:00 CET 1970' for 'null Converter'. )]



                    Do I have to add a converter or is there an error in the code?

                    • 7. Re: s:selectItems's itemValue usage
                      Pete Muir Master

                      You need a date converter.