2 Replies Latest reply on Sep 19, 2008 11:08 AM by oman moony

    s:selectItems - Newbie Problem

    oman moony Newbie


      I have a pretty simple dropdown...

      <h:selectOneMenu value="#{ad.business}">
      <s:selectItems value="#{adCreate.businesses}"  />

      I have the adCreate class:

      private List<Business> business; //with setters and getters

      and the adCreate class on init sets said businesses property:

      public void initAdCreate(){
        this.businesses =  em.createQuery("select b from Business b").getResultList();

      But for the life of me I cant get it to populate the dropdown and set the value of the Ad.business property and submission.

      I have tried so many things - i have tried making the List a list of SelectItems, adding the

      <convertEntity />

      tag to the selectOne, using a Map with the key being the business id and the value the business object, and many, many other things.

      Even a pointer to a good website with a Tutorial would be great.

      I'm sure this isn't too hard... but I'm just not getting it.

      Thanks heaps.

        • 1. Re: s:selectItems - Newbie Problem
          Damian Harvey Apprentice

          Have a look at the examples that come with Seam. They cover all of this.


          1. this.businesses is an entity so you need <s:convertEntity/> (don't forget the s namespace)

          2. your h:selectOneMenu value refers to #{ad.business} but looks like it should be #{adCreate.business}.

          3. using a list is fine. If you return a list of SelectItems then you should use <f:selectItems> instead of <s:selectItems>

          4. how is initAdCreate() called? You should annotate it with @Create if you want it created when the Bean is instantiated.

          • 2. Re: s:selectItems - Newbie Problem
            oman moony Newbie

            Nice one Damian!

            here is a great example:


            very helpful :)