5 Replies Latest reply on Sep 20, 2012 2:49 AM by ramram888

    Combobox setting value

    msantana

      Hello,my name is Matias and i´m new to Seam Framework.
      I am making a lot of tests, before i decide to make my project with it.


      I have a simple-for-you-problem, but i spend a lot of hours trying to figured it out, without success.
      I make a project using seam gen of a simple, product with categoria entity.
      The scenario is simple like this. I have a product which has a category. Simply.
      The sem-gen made a view where i can put the name of the client. But insted of make a comobox with all roles i can select it makes a grid where i have to enter to the page of roles and select one.


      So i decided to put a combo there, And here's where i get stucked.
      I made this:


       <s:decorate id="categoriaField" template="layout/edit.xhtml">
                      <ui:define name="label">Categoria</ui:define>
                      <rich:comboBox value="#{productoHome.instance.categoria.categoriaId}"
                                           suggestionValues="#{categoriaServiceBean.findAll()}" 
                                           defaultLabel="Seleccione..." 
                                           required="true"
                                           directInputSuggestions="true" />   
                                          <s:selectItems var="categoria" itemLabel="#{categoria.descripcion}" itemValue="#{categoria.categoriaId}" />
                          <a:support event="onblur" reRender="categoriaField" bypassUpdates="true" ajaxSingle="true"/>
                  </s:decorate>



      But the problem is that when i select the category i want, the event is not setting the value to productoHome.instance.categoria. Then  my save button is not settibn enabled.


      <h:commandButton id="save"
                                value="Save"
                               action="#{productoHome.persist}"
                             disabled="#{!productoHome.wired}"
                             rendered="#{!productoHome.managed}"/>



      Where am i wrong? what am i doing wrong?


      Thanx all!!

        • 1. Re: Combobox setting value
          msantana

          Someone who has a clue?

          • 2. Re: Combobox setting value
            stefanotravelli

            There are several problems in your code.


            The first is that the value property for rich:combobox points to the categoria.categoriaId. This won't work. Look at the <s:convertEntity>. Your code should look like:




            <rich:comboBox value="#{productoHome.instance.categoria}"
                      defaultLabel="Seleccione..." 
                      required="true"
                      directInputSuggestions="true" />   
                <s:selectItems 
                     var="categoria"
                     value="#{categoriaServiceBean.findAll()}" 
                     label="#{categoria.descripcion}" 
                     itemValue="#{categoria}" />
                <s:convertEntity/>
            </rich:comboBox>
             
            


            In order to enable the save button you also have to modify the isWired() method so that it doesn't check if categoria is null. The pattern for wired/not wired entity home needs a page refresh to work.


            • 3. Re: Combobox setting value
              msantana

              YES!! It work but the combobox is showing me the items with numbers! but the numbers aren´t the id´s however i want to show the descripition of the object, or the toString().


              IF you have ideas I will be very thankful to you!!!

              • 4. Re: Combobox setting value
                williamfitz

                What is easy and what is difficult? Easy is to judge others mistakes and difficult is to recognize our own mistakes.Write My Essay For Me

                • 5. Re: Combobox setting value
                  ramram888

                  Matias,

                   

                    <rich:combo> works as a suggestion box and supports only a list of characters. your are using the below :

                   

                  <s:selectItems var="categoria" itemLabel="#{categoria.descripcion}" itemValue="#{categoria.categoriaId}" />

                   

                  instead use :

                   

                  <s:selectItems var="categoria" itemLabel="#{categoria.categoriaId}" itemValue="#{categoria.descripcion}" />

                   

                  the itemValue appears in the combo list and not the itemLabel. <rich:combo> is different from <h:selectOneMenu>.

                   

                  Regards,