Hello All ,
This tutorial is based on use of selectManyListbox & selectManyCheckbox component in ADF to enable multiple selection.
Both component are same in functionality only somewhat different in look-feel.
Follow steps to use these component -
Select All-
Complete code written on 'Get Selected Values' button-
Cheers- Download Sample
This tutorial is based on use of selectManyListbox & selectManyCheckbox component in ADF to enable multiple selection.
Both component are same in functionality only somewhat different in look-feel.
Follow steps to use these component -
- Create a fusion web application and create business components for Departments table of HR Schema
- Now create a page and drop Departments Vo from data control on page as multiple selection (checkbox or listbox)
- Now binding for this component is created in page-bindings, add a button on page to get total selected values
- See how to get selected values in managed bean, JUCtrlListBinding is used to get selected values
- this method works for both listbox and checkbox, i have added all selected departments in a FacesMessage and displayed on page
import javax.faces.event.ActionEvent; import oracle.adf.model.BindingContext; import oracle.binding.BindingContainer; import oracle.jbo.uicli.binding.JUCtrlListBinding; public BindingContainer getBindings() { return BindingContext.getCurrent().getCurrentBindingsEntry(); } public void getSelectedValue(ActionEvent actionEvent) { JUCtrlListBinding listBindings = (JUCtrlListBinding)getBindings().get("DepartmentsView1"); Object str[] = listBindings.getSelectedValues(); for (int i = 0; i < str.length; i++) { System.out.println(str[i]); } }
Select All-
Complete code written on 'Get Selected Values' button-
/**Method to get BindingContainer of page * @return */ public BindingContainer getBindings() { return BindingContext.getCurrent().getCurrentBindingsEntry(); } /**Method to get Selected Values * @param actionEvent */ public void getSelectedValue(ActionEvent actionEvent) { JUCtrlListBinding listBindings = (JUCtrlListBinding)getBindings().get("DepartmentsView1"); Object str[] = listBindings.getSelectedValues(); StringBuilder saveMsg = new StringBuilder("<html><body><b><p style='color:red'>Selected Departments are-</p></b>"); saveMsg.append("<ul>"); for (int i = 0; i < str.length; i++) { System.out.println(str[i]); saveMsg.append("<li> <b>" + str[i].toString() + "</b></li>"); } saveMsg.append("</ul><br>"); saveMsg.append("</body></html>"); FacesMessage msg = new FacesMessage(saveMsg.toString()); FacesContext.getCurrentInstance().addMessage(null, msg); }
Cheers- Download Sample