0 Replies Latest reply on Oct 15, 2015 9:27 AM by vidyasagar penugonda

    RF-4.5.x How to get PickList selected Items in backing bean

    vidyasagar penugonda Novice

      Hi,

       

      I have a PickList and I want to take the selected items from the component and persist in DB. but I am not sure on how to get the selected values in my backing bean class. below is my code. Is there any method to get the target values from PickList.

       

      <rich:pickList id="userListShuttle"

             binding="#{sampleBean.pickLst}"

             var="roles"

             value="#{sampleBean.newRoles}"

             sourceCaption="Available Roles"

             targetCaption="Assigned Roles"

             listWidth="440px" listHeight="145px"

             orderControlsVisible="false"

             fastOrderControlsVisible="false">

             <f:selectItems value="#{sampleBean.availableRoles}"/>

      </rich:pickList>

       

      Java Code:

      ----------------

      @Component( "sampleBean" )

      @Scope( "request" )

      public class SampleBean {

       

          private List<String> newRoles;   

          private List<String> availableRoles;   

          private UIPickList pickLst = new UIPickList();

       

           /**

           * @return the newRoles

           */

          public List<String> getNewRoles() {

              newRoles = new ArrayList<String>();       

              newRoles.add( "Role 3" );

              newRoles.add( "Role 4" );

              newRoles.add( "Role 5" );

              newRoles.add( "Role 6" );

              Collections.sort( newRoles );

              return newRoles;

          }

       

          /**

           * @param newRoles the newRoles to set

           */

          public void setNewRoles( List<String> newRoles ) {

              this.newRoles = newRoles;

          }

       

          /**

           * @return the availableRoles

           */

          public List<String> getAvailableRoles() {

              availableRoles = new ArrayList<String>();

              availableRoles.add( "Role 1" );

              availableRoles.add( "Role 2" );

              availableRoles.add( "Role 3" );

              availableRoles.add( "Role 4" );

              availableRoles.add( "Role 5" );

              availableRoles.add( "Role 6" );

              Collections.sort( availableRoles );

              return availableRoles;

          }

       

          /**

           * @param availableRoles the availableRoles to set

           */

          public void setAvailableRoles( List<String> availableRoles ) {

              this.availableRoles = availableRoles;

          }

       

          /**

           * @return the roleShuttle

           */

          public UIPickList getPickLst() {

              return roleShuttle;

          }

       

          /**

           * @param roleShuttle the roleShuttle to set

           */

          public void setPickLst( UIPickList pickLst) {

              this.pickLst= pickLst;

          }

      }

       

      Thanks in advance.