2 Replies Latest reply on Jul 29, 2008 12:50 PM by 1womps1

    Dynamic listbox in jsp

    1womps1

      Hi i'm a beginner,and i'm trying to add a dynamic listbox to a jsp,i am asked to developp a listbox which will be a list of beans results of an sql request.i have already developped the bean here it is.


      @Entity
      @Table(name="ds_documents")
      public class ListderoulanteBean implements Serializable{    
           
               long    id_doc;
               String  intitul_doc;
               long    id_categorie;
      
               @Id @GeneratedValue
               @Column(name="id_doc")
               public long getIdDoc() {
                   return id_doc;
               }                    
               public void setIdDoc(long id_doc) {
                  this.id_doc = id_doc;
               }     
      
               @Column(name="intitul_doc",unique=true,nullable=false,length=50)
               @NotNull 
               @Length(min=4,max=16)
               public String getintitulDoc() {
                   return intitul_doc;
               }
               public void setintitulDoc(String intitul_doc) {
                   this.intitul_doc = intitul_doc;
               }
      
               
               @Column(name="id_categorie")
               public long getIdcategorie() {
                   return id_categorie;
               }                    
               public void setIdcategorie(long id_doc) {
                   this.id_doc = id_doc;
               }    
               
      }
      



      What is the next step ?do i need a servlet which will include an sql request? and how could i show the results in my listbox.
      Thanks for you help

        • 1. Re: Dynamic listbox in jsp
          digdas.seam.digdas.nl

          You can create a list object (in actions)


          @Name("deroulanteList")
          public class ListderoulanteBean List extends EntityQuery
          {
              @Override
              public String getEjbql() 
              {          
                  return "select listderoulanteBean from ListderoulanteBean listderoulanteBean ";
              }
          }



          and then use this in your xhtml-page.


          <h:selectOneMenu id="seamentity" value="#{seamhometoedit.instance.field}" required="true">
            <s:selectItems value="#{deroulanteList.resultList}"
             var="ou" label="#{ou.name}" />
            <s:convertEntity />
          </h:selectOneMenu>


          • 2. Re: Dynamic listbox in jsp
            1womps1

            Thanks very much that works with some changes :)