11 Replies Latest reply on Nov 11, 2010 9:47 AM by Tony Tony

    Dynamic generate richfaces controls in a datatable

    Tony Tony Newbie

      Ok, I'll try to explain my problem.

       

      I have a rich:datatable, which  renders rows based on a datatype. One column of the datatable depends on one property of that datatype (ControlType property). Depending on that field, I have to render a combobox, or a textbox, or a checkbox list, or a grid, in that column.

       

      I think I need to create that controls programatically (create UIPanel, UIComboBox, UITextBox, etc). I Created a panel in my .xhtml and bind it to a UIPanel in the backing bean. There I can place personalized controls inside my panel, but the getter of that property in the backing bean fires just one time during page load and doesnt fire for each row.

       

      <rich:panel binding="#{viewForm.panelRes}" >                           
      </rich:panel>

       

      public UIPanel getPanelRes() {

           if (bindColumnGroup.isRowAvailable()) {
                  Question l_quest = (Question) bindColumnGroup.getRowData();
                  panelRes = new HtmlPanel();
                  UIComponent c;
                  if (l_quest.getType() == ControlType.COMBO)
                  {
                      c = new HtmlComboBox();
                      panelRes.getChildren().add(c);
                  }
                  else
                  {
                      if (l_quest.getType() == ControlType.TEXT)
                      {
                          c= new HtmlInputText();
                          panelRes.getChildren().add(c);
                      }               
                  }   

                     ///////        etc, etc, etc (More controls
            }

           return panelRes;

             
          }
            

       

       

      Hoy can I achieve that? Help!!

       

      (Sorry my bad english)