4 Replies Latest reply on Feb 4, 2013 5:18 AM by Siva P

    set destination  rich:picklist

    Ganesh Amande Newbie

      In rich:picklist i want to set the destination picklist which is coming from backing bean and i'm using jsf  2.0

      Thanks In Advance.

        • 1. Re: set destination  rich:picklist
          iabughosh Master

          welcome to the community Amande,

          try this :


          <rich:picklist value="#{myBean.selectedValues}">

               <f:selectItems value="#{myBean.sourceValues}" var="item" itemValue="#{item}" itemLabel="#{item}"/>



          where selectedValues is List<String> has these values {"Item 1","Item 2"}

          and sourceValues is List<String> has there values {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"}


          Good Luck.

          • 2. Re: set destination  rich:picklist
            Ganesh Amande Newbie

              <f:selectItems value="#{myBean.sourceValues}" var="item" itemValue="#{item}" itemLabel="#{item}"/>


            solution provided above is working fine but its change my  source list because of this source list printing employee object  instead of  employee name  .

            source list is


              <f:selectItems value="#{myBean.sourceValues}" var="item" itemValue="#{item.id}" itemLabel="#{item.name}"/>

            • 3. Re: set destination  rich:picklist
              Siva P Master

              Hi Amande,


              If you are using richfaces with seam means you can try with the below code....Home is nothing but BEAN class for your reference.

              XHTML page:

              <a4j:region renderRegionOnly="true">

              <rich:pickList id="userinfo"





              moveControlsVerticalAlign="middle" listsHeight="400px"

              style="marigin-left:-2px;" sourceListWidth="250px"



              <s:selectItems value="#{emptrainingrolemappingHome.trainingRolesSelectItemList}" var="role"





              <h:panelGrid id="panelgrdID" width="100%">

              <rich:toolBar id="toolbarButton" width="100%"



              <a4j:commandButton  id="savebtnID"







              In the Bean class create like below,


              private List<Entity class or POJO class> resultRoles = new ArrayList<Entity class or POJO class>();

              List<Entity class or POJO class> trainingRolesSelectItemList = new ArrayList<Entity class or POJO class>();



                  public List<Entity class or POJO class> getTrainingRolesSelectItemList() {       

                      return trainingRolesSelectItemList;




                  public void setTrainingRolesSelectItemList(

                          List<Entity class or POJO class> trainingRolesSelectItemList) {       

                      this.trainingRolesSelectItemList = trainingRolesSelectItemList;



                public List<Entity class or POJO class> getResultRoles() {

                      return resultRoles;



                  public void setResultRoles(List<Entity class or POJO class> resultRoles) {

                      this.resultRoles = resultRoles;



              To save the data in the database after moving it to right side pick list:


              public String persistRoles() {


                      if (resultRoles.size() == 0) { ///throws error for selecting one to right side



                      } else {

                          //get existing mapped Roles

                          List<Entity class or POJO class> alreadyAssignedRoles = getAvailRoles();


                         //here suppose if alrady existing datas should be deleted from DB  and add the new list into it always .That is ood programming


                          for (int j = 0; j < alreadyAssignedRoles.size(); j++) {

                              Entity class or POJO class  etrm = (Entity class or POJO class) alreadyAssignedRoles.get(j);





                      // Iterate the resultRoles and insert into the DB here //****************** do your code*****************






                      return "persisted";



              I hope i have give correct way to picklist for storing into DB........