1 Reply Latest reply on Dec 20, 2007 1:03 PM by Pete Muir

    Dynamically rendering more than one select elements in a for

    Kindor Bazul Newbie

      I'm trying to dynamically build a form by looping over a set of fields that have a renderer attribute, which is used to tell what widget should be used to renderer them.

      The problem I'm facing is when the widget is a select element. In this case, the nested f:selectItems load their data from a bean that, if I understand well the documentation, cannot be specified at runtime. Thus, I have hardcoded the bean that provides the data to the select boxes (dataProviderBean.selectItems in my simplified example below). But when the form is rendering, I haven't found any mean by which dataProviderBean can know which select element is being populated.

      What's the best approach for solving this problem ?

      <h:dataTable var="field" value="#{fieldSet}">
       <h:inputText value="#{field.value}"
       <h:selectManyListbox value="#{field.value}"
       <f:selectItems value="#{dataProviderBean.selectItems}"/>
       <h:selectManyCheckbox value="#{field.value}"
       <f:selectItems value="#{dataProviderBean.selectItems}"/>