5 Replies Latest reply on May 29, 2014 3:40 PM by Oluseyi Bucknor

    Default Right side values of a rich:pickList not getting populated.

    Its Me Newbie

      Hello All,

       

      The following is the code which we are using in our rich:pickList:

       

      <rich:pickList value="#{myBean.defaultData}">

                                              <f:selectItems value="#{myBean.allData}"/>

                                          </rich:pickList>

       

      the defaultData is a String [] = new String[] {"test1","test2"};

       

      And the allData is a List<SelectItem>. Both the variables are declared private in the bean and have the corresponding getter and setter.

       

      The left side of the picklist gets populated.... but there are no default elements selected. The getter and setter's of the defaultData are being called though.

       

      Any help on this one is appreciated.

       

      Thanks And Regards,

      Nid.................................

        • 1. Re: Default Right side values of a rich:pickList not getting populated.
          iabughosh Master

          hello Nid,

          ensure that allData (List<SelectItem>) contains at least new SelectItem("test1") and new SelectItem("test2").

           

          hint: if you are using JSF 2 and your select item and label are the same you can replace List<SelectItem> with List<String> and add items like this list.add("test1").

           

          regards.

          • 3. Re: Default Right side values of a rich:pickList not getting populated.
            Ramaraj Vanarajan Newbie

            i am also getting same problem i am geting values from left hand sides but not geting values in right sides

             

             

             

            <rich:pickList id="programSelect"  value="#{circularController.selectedUsersList}"

                                                    var="items" sourceCaption="#{msg.available_List}"

                                                    targetCaption="#{msg.selected_List}" listHeight="100"

                                                     required="true"

                                                    requiredMessage="Please select from available list">

                                                    <f:selectItems value="#{circularController.usersList}"></f:selectItems>

                                                    <rich:column>

                                                        <h:outputText value="#{items}"></h:outputText>

                                                    </rich:column>

                                                </rich:pickList>

             

             

            value={circularController.selectedUsersList}   it is fetching values from db as a List<String> selectedUsersList;

             

             

            i dont know where i did wrong please help me

            • 4. Re: Default Right side values of a rich:pickList not getting populated.
              Brian Leathem Master

              Ramaraj, try specifying a converter that can be used to identify when your users are equivalent (using a id or key value for instance).

              • 5. Re: Default Right side values of a rich:pickList not getting populated.
                Oluseyi Bucknor Newbie

                Hi Brian,

                 

                I was wondering if you could please help. I am experiencing a similar challenge. When I do something like this in my backing bean it works fine:

                 

                private String [] testRight;

                  private String [] testLeft; (with getters and setters)

                 

                public void initalizeLeftRightSide2()

                    {

                        this.testLeft = new String[5];

                        this.testRight = new String[2];

                 

                        testLeft[0] = "module1";

                        testLeft[1] = "module2";

                        testLeft[2] = "module3";

                        testLeft[3] = "module4";

                        testLeft[4] = "module5";

                      

                        testRight[0] = "module2";

                        testRight[1] = "module4";

                    }

                 

                But when I do it with my Module objects the right side does not get populated:

                 

                private List<Modules> allModules;

                private List<Modules> forSelectedRole;

                 

                public void initalizeLeftRightSide3(Long selectedRoleID)

                    {

                         this.allModules = modRole.getAllModules();

                        Roles theRole = modRole.getModuleListByRoleID(selectedRoleID);

                        this.forSelectedRole = theRole.getModulesLst();

                    }

                 

                My JSF to initialize the pickList is this with a converter implemented:

                <rich:pickList  value="#{addModuleToRole.forSelectedRole}" sourceCaption="Available Modules" targetCaption="Selected Modules" listWidth="200px" listHeight="200px" >

                                       <f:selectItems value="#{addModuleToRole.allModules}" var="moules" itemValue="#{moules}" itemLabel="#{moules.name}" />

                                   <f:converter converterId="modulesConverter" />                     

                </rich:pickList>

                 

                Just to add forSelectedRole is a subset of allModules.

                 

                Thanks in advance for any assistance.