ADF Select Many Listbox / Select Many Checkbox LOV
Few days back ,I was looking for an inbuilt feature of multi-select LOV in ADF and was quite surprised that ADF does not have this feature as a part of available LOV bindings.We cannot bind the LOV's to a selectManyListBox directly.To Achieve this we need to use a managed bean to dispatch between the ADF binding layer and the multi select component.The ADF selectManyListbox component allows the user to select many values from a list of items. It can contain any number of <f:selectitem>, <f:selectitems>, or <af:selectitem> components, each of which represents an available option that the user may select.
A typical ADF Multi select LOV looks like this :
<af:selectmanylistbox required="yes" value="#{bean.aValue}">
<f:selectitem itemlabel="Option1" itemvalue="1">
<f:selectitem itemlabel="Option1" itemvalue="2">
</f:selectitem></f:selectitem></af:selectmanylistbox>
Step 1 :
1) Prepare a List of items that your Multi select LOV holds in a Managed Bean.The SelectManyListbox and -Choice value property writes/reads its value to/from a List (e.g. ArrayList)
private List<selectitem> actualList;
public MultiSelect() {
super();
actualList = new ArrayList<selectitem>();
actualList.add(new SelectItem("ACTIVE", "ACTIVE"));
actualList.add(new SelectItem("INACTIVE", "INACTIVE"));
actualList.add(new SelectItem("COMPLETED", "COMPLETED"));
2)
Drag and drop the selectManyListbox component from Jdev Component palette on to the page and bind it to the list created above from managed bean. After creating list it should look like below code .Also create an another list with getters and setters in the managed bean and bind to the value property of af:selectManyListbox manually.
<af:selectManyListbox label="Label 1" id="sml1"
value="#{backingBeanScope.MultiSelect.lovValue}">
<f:selectItems
id="si2"
value="#{backingBeanScope.MultiSelect.actualList}"/>
</af:selectManyListbox>
private List<selectitem> lovValue;
public void setLovValue(List<selectitem> lovValue) {
this.lovValue = lovValue;
}
public List<selectitem> getLovValue() {
return lovValue;
}
Input screen :
After checking the required value click the commandbutton and in the jdev console you will see the output like this
Selected Value:ACTIVE
Selected Value:COMPLETED
All you need to do is when the getter is called you make sure the data
is read from where it is created .when you write back take the list
transform its entries in to the way you want. some may want to create
comma delimited list of string,semi-colon separated ,individual strings
which they want to store in DB .
ADF
currently doesn't support binding the selectManyListBox value to the VO
attribute directly this is the approach that I have followed as
workaround!!
thank you.
ReplyDeletepython3 tutorial
Hibernate tutorial