3 Replies Latest reply on Dec 7, 2007 11:24 AM by Romain Taz

    Problem with Suggestionbox inside Datatable with checkbox

    Romain Taz Newbie

      Hi all,

      I have a very strange problem using SuggestionBox, DataTable and checkboxes.

      Here is what I need to do:

      A datatable, with a checkbox on front of each row (for multiple row selection feature), and a suggestion box in one column of the row.

      Thus, I wrote the following code on the JSF page:

      <h:form>
       <rich:dataTable value="#{fake.elements}" var="elt">
       <rich:column>
       <f:facet name="header">
       <h:selectBooleanCheckbox/>
       </f:facet>
       <h:selectBooleanCheckbox/>
       </rich:column>
       <rich:column>
       <f:facet name="header">
       <h:outputText value="Description"/>
       </f:facet>
       <h:inputText id="sugg" value="#{elt.description}" styleClass="std"/>
       <rich:suggestionbox height="200" width="200" for="sugg" suggestionAction="#{fake.autocomplete}" var="suggest">
       <h:column>
       <h:outputText value="#{suggest.description}"/>
       </h:column>
       </rich:suggestionbox>
       </rich:column>
       </rich:dataTable>
      </h:form>
      


      This does not work. In fact, the suggestion box appears and work correctly only for the last row! If my datatable displays 3 rows, the third one will work correctly, but NOT the two first rows.
      The Java method autocomplete on my bean is called, executed and returns the list. But nothing is displayed.
      I used the IE Developper Toolbar and I saw that both DIV and IFRAME are added to my page (used to contains the DIV of the suggestion box), but are not displayed.

      Now, I just only removed the checkbox on the header of the first column of my datatable, i.e. I have this code now:

      <h:form>
       <rich:dataTable value="#{fake.elements}" var="elt">
       <rich:column>
       <f:facet name="header">
       <rich:spacer/>
       </f:facet>
       <h:selectBooleanCheckbox/>
       </rich:column>
       ...
       </rich:dataTable>
      </h:form>
      


      ...and now it works!
      The suggestion box appears in all row, and not only for the last one. In fact, the behavior is not perfect yet, as the suggestion box appears only at the second characters instead at the first one typed by the user (the suggestion box is correct on the last row).

      Do you have any idea why this error occurs?
      Do you have any idea how to solve this problem?

      Thanks in advance.

      Regards.

      Romain


        • 1. Re: Problem with Suggestionbox inside Datatable with checkbo
          Romain Taz Newbie

          Hi again,

          I made another test, which "works" (i.e. the suggestionbox appears for all rows, but after the second character for any row which is not the last row):
          I built my datatable by defining all headers, and then all column content.

          My code is the following now:


          <h:form>
           <rich:dataTable value="#{fake.elements}" var="elt">
           <f:facet name="header">
           <rich:columnGroup>
           <rich:column>
           <h:selectBooleanCheckbox/>
           </rich:column>
           <rich:column>
           <h:outputText value="Description"/>
           </rich:column>
           </rich:columnGroup>
           </f:facet>
          
           <rich:column>
           <h:selectBooleanCheckbox/>
           </rich:column>
           <rich:column>
           <h:inputText id="sugg" value="#{elt.description}" styleClass="std"/>
           <rich:suggestionbox height="200" width="200" for="sugg" suggestionAction="#{fake.autocomplete}" var="suggest">
           <h:column>
           <h:outputText value="#{suggest.description}"/>
           </h:column>
           </rich:suggestionbox>
           </rich:column>
           </rich:dataTable>
          </h:form>
          


          However, I really need to understand why my first example does not work!

          Romain


          • 2. Re: Problem with Suggestionbox inside Datatable with checkbo
            Romain Taz Newbie

            For information, I work with version 3.1.2 of Richfaces.
            I tried the version 3.1.2.SP1 but the problem still occurs.

            • 3. Re: Problem with Suggestionbox inside Datatable with checkbo
              Romain Taz Newbie

              Hi again,

              I found a way to make my code working: I just defined the value attribute for the checkbox that is in the header of the column:

              ...
              <rich:dataTable value="#{fake.elements}" var="elt">
               <rich:column>
               <f:facet name="header">
               <h:selectBooleanCheckbox value="#{fake.checked}"/>
               </f:facet>
               <h:selectBooleanCheckbox/>
               </rich:column>
               ...
              


              However, I still get the problem where I need to type 2 characters the first time on any row, except the last one, to have the suggestion box displayed...

              I still don't understand why the suggestion box does not appear without the value attribute in the checkbox...