Monday 4 November 2013

Use of selectManyShuttle in ADF

This below blog we will see how to use selectManyShuttle in ADF.

Now create a fusion ADF application in jDeveloper then add one <af:selectManyShuttle> in UI page and set the value=”selected values”. Inside the same tag add one sub tag <f:selectItems> and set the value=”all values”.

JSPX page:
<af:selectManyShuttle label="Label 1" id="sms1"
                 binding="#{backingBeanScope.backing_SelectManyShuttle.sms1}"
                 value="#{backingBeanScope.backing_SelectManyShuttle.selectedValues}">
     <f:selectItems value="#{backingBeanScope.backing_SelectManyShuttle.allValues}"             id="si1" binding="#{backingBeanScope.backing_SelectManyShuttle.si1}"/>
</af:selectManyShuttle>

Note:- All values are instance of javax.faces.model.SelectItem and selected values are just values in list which are part of all values.

Now we need to write the selectedValues() and allValues() methods in backing bean. 

Backing Bean:-
List selectedValues = new ArrayList();
List allValues = new ArrayList();
public void setSelectedValues(List selectedValues) {
    this.selectedValues = selectedValues;
}
public List getSelectedValues() {
    selectedValues.add("Right1");
    selectedValues.add("Right2");
    selectedValues.add("Right3");
    return selectedValues;
}
public void setAllValues(List allValues) {
    this.allValues = allValues;
}
public List getAllValues() {
    allValues.add(new javax.faces.model.SelectItem("Right1"));
    allValues.add(new javax.faces.model.SelectItem("Right2"));
    allValues.add(new javax.faces.model.SelectItem("Right3"));
    allValues.add(new javax.faces.model.SelectItem("Left1"));
    allValues.add(new javax.faces.model.SelectItem("Left2"));
    allValues.add(new javax.faces.model.SelectItem("Left3"));
    return allValues;
}

Now run your application and the UI page will come like
See the Right1, Right2 and Right3 are in selected list on the right hand side and rest all the values form the all values will display in left side.
Here we can move the components from left side to right side in shuttle component.
You can download the code:Download
Thanks...


No comments:

Post a Comment