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)
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>
Now create an ADF button and action listener to a custom method in the managed bean.Inside the method write this code and you ll get the values which are being selected/checked by the user.
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)
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>
Now create an ADF button and action listener to a custom method in the managed bean.Inside the method write this code and you ll get the values which are being selected/checked by the user.
can we get the sample project for the same
ReplyDeletehmm .. i have given complete code snippet.. u need to just put in the right place. i can assist u if u have any issue..
DeleteHi Anantha,
DeleteCan you tell me how can we achieve remove functionality of selected items. Would be of great help.
Thanks,
Animesh
Nice guide, just what i needed for my project. Thanks!
ReplyDeletecan we have a modified use case here. I will have a button here and name it remove selected. so user will select against the checkbox items and click on remove. Those items get completely removed. Any idea how to achieve this
ReplyDelete