5 Replies Latest reply on Jan 29, 2008 5:18 AM by panky_p

    s:selectItem problem while persisting

    panky_p

      Hi I am trying to save to database the value selected from list but it is saving it as object of selectItem
      my xhtml code is

      <h:selectOneMenu id="carList" value="#{carBean.carCategory}">
      <s:selectItems var="carCategory" value="#{carDetail.carCategoryList}"
      label="#{carCategory.label}" noSelectionLabel="Select Car Category..."/>
      </h:selectOneMenu>

      and my list is
      public List<SelectItem> carCategoryList()
      {
       get values for car list from database such as Audi, BMW etc
      }
      

      it works fine till populating list and retriving data from database as well but in database i want to store it as string "Audi" instead it saves it as object string
      javax.faces.model.SelectItem@15817ba

      can any one help me how can i store it as an actual string??

      Thanks
      Panky

        • 1. Re: s:selectItem problem while persisting
          nickarls

          Does the corresponding h:selectItems work?

          • 2. Re: s:selectItem problem while persisting
            lazar.mihai

            nickarls can u please shed some light on what s:selectItems and f:selectItems are doing ?

            From what I figure they both return a SelectItem.

            I'm trying to make it return a class value and bind it to a componentHome.instance.theclass

            • 3. Re: s:selectItem problem while persisting
              lazar.mihai

              What I've done is like this

              Create a new JBoss Seam Project
              EAR
              Seam 2.0.0.GA
              JBoss 4.2.0.GA

              Copy paste the entites from ContactList example
              Contact
              Comment

              Seam Reverse Engineer entities from source code

              (I'm using a MySQL connection that part works)

              Now .. in the Comment List
              when selecting New Comment in the CommentEdit.xhtml I'd like to be able to select a contact form a drop down list instead of the default auto-generated way.

              If u can make something like this work please post back :D

              • 4. Re: s:selectItem problem while persisting
                nickarls

                Well, if you are juggling entities you might as well use a List and bind to the entityHome.entity and use a convertEntity (remembering to override hashcode() and equals() on the entity id). There are plenty of threads on this.

                • 5. Re: s:selectItem problem while persisting
                  panky_p

                  Well guys it will create complexity by using convert entity and al that.

                  I am getting list populated with the data what i want the only problem was i was not getting it stored as string what i want instead it was storing object of select item
                  so better i used <f:selectItems> and works fine for me.

                  Thanks for reply
                  Panky