3 Replies Latest reply on Aug 26, 2010 1:28 PM by cassionandi

    rich:comboBox shows strange results

    ondaviolenta

      Hi, guys. i'm a newbe in java and i need your help.

       

      The Problem

       

      I extract the results from a query (15 records):

       

      public List<Soggetto> getAllSoggetti() {
              List<Soggetto> menuList = entityManager.createQuery("Select n from Soggetto as n").getResultList();
              return menuList;   
          }

       

      If I use h:selectOneMenu, it works. Instead , if I use rich:comboBox the results are displayed in a strange way. combobox dislpays for 15 time  com.mydomain.pkg.model.Soggetto@61 as result .

       

      See the 2 example

       

      DON'T WORK

       

      <rich:comboBox selectFirstOnUpdate="false" directInputSuggestions="true" defaultLabel="Enter some value">
            <s:selectItems var="thing" value="#{extractor.allSoggetti}" label="#{thing.codiceFiscale}  #{thing.cognome}  #{thing.primoNome}   #{thing.secondoNome}  #{thing.ragioneSociale}" noSelectionLabel="Selezionare un soggetto destinatario" hideNoSelectionLabel="true"  />
      </rich:comboBox>

       

      s_ko.jpg

       

      ======================================================================================================

       

      WORKS

       

      <h:selectOneMenu value="#{comunicazione.destinatario}" required="true">
                          <s:selectItems var="thing" value="#{extractor.allSoggetti}" label="#{thing.codiceFiscale}  #{thing.cognome}  #{thing.primoNome}  #{thing.secondoNome}  #{thing.ragioneSociale}" noSelectionLabel="Selezionare un soggetto destinatario" hideNoSelectionLabel="true"/>
                          <s:convertEntity/>
                     </h:selectOneMenu>

       

      s_ok.jpg

       

      Someone can help me, please ?

       

      Thanks in advance

        • 1. Re: rich:comboBox shows strange results
          ilya_shaikovsky

          add the same s:convertEntity to comboBox

          • 2. Re: rich:comboBox shows strange results
            ondaviolenta

            Using <s:convertEntity/> the combobox shows only a incremental number list. the numbers are not the records ID on database.

             

             

            <rich:comboBox selectFirstOnUpdate="false" directInputSuggestions="true" defaultLabel="Enter some value">
                                 <s:selectItems var="thing" value="#{extractor.allSoggetti}" label="#{thing.codiceFiscale}  #{thing.cognome}  #{thing.primoNome}  #{thing.secondoNome}  #{thing.ragioneSociale}" noSelectionLabel="Selezionare un soggetto destinatario" hideNoSelectionLabel="true"  />
                              <s:convertEntity/>       
                          </rich:comboBox>

             

             

             

            sc_ko.jpg

            • 3. Re: rich:comboBox shows strange results
              cassionandi

              I have the same problem as firtly described. But I am not <s:convertEntity/> on my project.

              There is some workaround to make the combobox show the defalt message?