2 Replies Latest reply on Feb 17, 2011 1:44 AM by ferilauw

    rich:suggestionbox multi field

    ferilauw

      Hi All,


      I have a problem, can other field have a value too from database ? because i want to have 2 property that have value from table in MySQL.
      In below, i just have one value from field : cabang.kota
      and i need one value again from other field : cabang.nama
      how to do that using just only one action like this below?
      Note : cabangList.autocomplete is the query.


      <div>Cabang</div>
       <div></div>
       <h:inputText id="kota" value="#{cabang.kota}"></h:inputText>          
        <rich:suggestionbox ajaxSingle="true" for="kota" var="_cabang"
           fetchValue="#{_cabang.kota}" minChars="1"
           suggestionAction="#{cabangList.autocomplete}"
           defaultLabel="Pilihan Cabang"
           nothingLabel="Cabang tidak ada!">
           <h:column>
               <h:outputText value="#{_cabang.kota}" />                    
           </h:column>
           <h:column>
              <h:outputText value="#{_cabang.nama}" />
           </h:column>
           <a:support event="onselect" reRender="cabangSearchResults" />
        </rich:suggestionbox>          
       <div></div>
       <div></div>
      



      Thanks you so much before.


        • 1. Re: rich:suggestionbox multi field
          kragoth

          Let's see.


          rich:suggestionBox only has a single value attribute so the simple answer to your question is no you can't use this component to assign values to two separate variables at the same time.


          BUT, with a bit of thinking you can do it.


          Instead of using the results of your query to build your suggestion list use the results to build a list of DTO objects that contain the combinations of the 2 values you want.


          Then, your suggestionbox should use the list of DTOs as it's suggestions.


          Then when the user selects a suggestion a valuechange listener could be used to extract the 2 values out of the DTO they selected and set the values on your actual object.


          This might require you to change how you load your page a bit but this should work.


          There are other ways to solve this problem but, I'd have to think about the solution a bit more before I try to write them down. :)

          • 2. Re: rich:suggestionbox multi field
            ferilauw

            Hi Sir Tim,


            Ok Sir Tim, i will try to learn about DTO with Seam because iam new in Seam and DTO :)


            Thanks you so much.