3 Replies Latest reply on Jul 14, 2009 4:53 PM by Nick Belaevski

    dynamic columns inside <rich:suggestionBox>

    Indu K Newbie

      I was trying to get my suggestion box to work with dynamic columns. I could get this to work using the c:forEach as shown below,

      <rich:suggestionbox id="suggestionBox" for="#{bean.userType}" var="suggestion" ...... ..>
      <c:forEach items="#{bean.displayColumns}" var="displayColumn" varStatus="rowCount">
       <h:column>
       <h:outputText value="#{suggestion.displayColumns[rowCount.index]}" />
       </h:column>
      </c:forEach>
      </rich:suggestionbox>
      


      But, I have a table and this suggestionBox is a component inside the table. So I cannot have c:forEach in there. Is there a way I can use ui:repeat, a4j:repeat or rich:columns instead of c:forEach in this use case. I tried and its not working. Why is rich:columns not supported inside rich:suggestionBox? Any ideas/help would be really appreaciated.
      Thanks!


        • 1. Re: dynamic columns inside <rich:suggestionBox>
          Ilya Shaikovsky Master

          could you create some small sample for us with mock data and share for investigation?

          • 2. Re: dynamic columns inside <rich:suggestionBox>
            Indu K Newbie

            On further investigation, turns out that it was because I am using the outer table's variable to create the dynamic columns and it won't evaluate that.
            So this is the difference. The first one doesn't work, but the second one does.

            <rich:dataTable id="grid" value="#{tableBean.list}" var="child" rowKeyVar="rowNum">
             <h:column>
             <a4j:region id="suggestBoxRegion" renderRegionOnly="true">
             <h:inputText id="studentType" value="#{child.studentType}"/>
             <rich:suggestionbox id="studentTypeSuggestions" for="studentType" var="suggestion" suggestionAction="#{child.filterSuggestions}"fetchValue="#{suggestion.studentType}" minChars="1" width="300">
             <f:facet name="nothingLabel">
             <h:outputText value="No matches found" />
             </f:facet>
             <rich:columns value="#{child.students}" var="displayColumn" index="rowCount">
             <h:outputText value="#{suggestion.displayColumns[rowCount]}" />
             </rich:columns>
             </rich:suggestionbox>
             </a4j:region>
             </h:column>
            </rich:dataTable>
            


            <rich:dataTable id="grid" value="#{tableBean.list}" var="child" rowKeyVar="rowNum">
             <h:column>
             <a4j:region id="suggestBoxRegion" renderRegionOnly="true">
             <h:inputText id="studentType" value="#{child.studentType}"/>
             <rich:suggestionbox id="studentTypeSuggestions" for="studentType" var="suggestion" suggestionAction="#{child.filterSuggestions}"fetchValue="#{suggestion.studentType}" minChars="1" width="300">
             <f:facet name="nothingLabel">
             <h:outputText value="No matches found" />
             </f:facet>
             <rich:columns value="#{staticBean.students}" var="displayColumn" index="rowCount">
             <h:outputText value="#{suggestion.displayColumns[rowCount]}" />
             </rich:columns>
             </rich:suggestionbox>
             </a4j:region>
             </h:column>
            </rich:dataTable>
            


            The only difference is <rich:columns value="#{staticBean.students}" ..> instead of <rich:columns value="#{iteratingVariable.students}" ..>

            Thanks !

            • 3. Re: dynamic columns inside <rich:suggestionBox>
              Nick Belaevski Master

              Hi,

              Such usage <rich:columns value="#{iteratingVariable.students}" ..> is illegal, check documentation for more.