4 Replies Latest reply on Aug 28, 2009 9:40 AM by marian ristouche

    UISelectMany selected values always NULL

    marian ristouche Newbie

      Hi everyone,

      I am facing a problem of fetching values out of a UISelectMany into an Object[]. I always get the Object value null.
      Here is what I try to do:
      - I have a JSP page using JSF, there is a RichFaces TabPanel in it that I bind with an HtmlTabPanel in my backing bean.
      - in this backing bean, I create some tabs, and add an UISelectMany to each tab
      - when I press the Submit button in the JSP page, I try to get the selected items from the UISelectMany
      Actually, I am trying to do this only with ONE tab, and therefore, ONE UISelctMany.

      Here is a part of my JSP:

      rich:tabPanel id="tabPanel" switchType="client" binding="#{dataBase.mytabPanel}" />
       <h:commandButton value="Sumit" action="#{dataBase.validateContent}"></h:commandButton>
      

      and here is a part of the backing bean:
      /** The method called by my Submit button*/
       public String validateContent(){
       for (int i=0; i<objValues.length; i++){
       if (selectMany.getSelectedValues()!=null) System.out.println("selected: " + selectMany.getSelectedValues());
       }
      
       return OUTCOME_CONTENT;
       }
      
       /**
       * The getter of HTMLTabPanel
       * @return HTMLTabPanel
       */
       public HtmlTabPanel getMytabPanel() {
       List<List<UISelectItem>> selectItemTab=SelectItemConverter.listMapToUISelectItems(dataBase.getListVarContent(chosenVariablesNames));
       /**create a tabPanel*/
       FacesContext context = FacesContext.getCurrentInstance();
       Application application = context.getApplication();
       mytabPanel = (HtmlTabPanel)application.createComponent(HtmlTabPanel.COMPONENT_TYPE);
       /**for each entry in the displayContentList, create a tab*/
       for (int i=0; i<selectItemTab.size();i++){
       HtmlTab tab = (HtmlTab)application.createComponent(HtmlTab.COMPONENT_TYPE);
       tab.setLabel("Variable: " + variableNames);
       /**the selectManyItems*/
       selectMany=new UISelectMany();
       selectMany.setSelectedValues(objValues);
       selectMany.getChildren().addAll(selectItemTab.get(i));
       tab.getChildren().add(selectMany);
       mytabPanel.getChildren().add(tab);
       }
       return mytabPanel;
       }
      

      My problem is that everything printed in the console is NULL.

      I searched everywhere for the solution, but I never found.May you please help me, it would be very much appreciated!