Requirement: I have a Shuttle Component where I will select a few Department Names. Now, there is a button with the name “Get Selected Values“. The moment I click on the “Get Selected Values” button it should display all the selected Department IDs in the console.
Solution: For solution of the above requirement follow the steps as shown below:
Step 1: Create an Oracle ADF Fusion Web Application.
Create a Business Components from Tables for the Departments table of the HR Schema of the Oracle Database 11g XE Edition.
Step 2: Create a shuttleDemo.jspx page. Drag and drop DepartmentVO1 from the Data Control palette on the shuttleDemo.jspx page as an ADF Select Many Shuttle component
The Multi Select Base Attribute will be DepartmentId, and the Multi Select Display Attribute will be DepartmentName.
This will ensure, that DepartmentName is getting displayed in the User Interface, and when we select the DepartmentName and click on the “Get Selected Values” button it should display all the selected Department IDs in the console.
Step 3: Drag and drop an af:button on the shuttleDemo.jspx page. Set the
text=”Get Selected Value” and actionListener=”#{pageFlowScope.MyBean.getSelectedValueAL}”
Thus, the complete code for shuttleDemo.jspx page is shown below:
<?xml version='1.0' encoding='UTF-8'?> <jsp:root xmlns:jsp="" version="2.1" xmlns:f="" xmlns:af=""> <jsp:directive.page contentType="text/html;charset=UTF-8"/> <f:view> <af:document title="shuttleDemo.jspx" id="d1"> <af:messages id="m1"/> <af:form id="f1"> <af:selectManyShuttle value="#{bindings.DepartmentsVO1.inputValue}" label="Department Name" id="sms1"> <f:selectItems value="#{bindings.DepartmentsVO1.items}" id="si1"/> <f:validator binding="#{bindings.DepartmentsVO1.validator}"/> </af:selectManyShuttle> <af:button text="Get Selected Value" id="b1" actionListener="#{pageFlowScope.MyBean.getSelectedValueAL}"/> </af:form> </af:document> </f:view> </jsp:root>
And, the complete code for the MyBean.java is as below:
package susantotech.com; import javax.faces.event.ActionEvent; import oracle.adf.model.BindingContext; import oracle.binding.BindingContainer; import oracle.jbo.uicli.binding.JUCtrlListBinding; public class MyBean { public MyBean() { } public void getSelectedValueAL(ActionEvent actionEvent) { BindingContainer bindingContainer = this.getBindings(); JUCtrlListBinding listBindings = (JUCtrlListBinding) bindingContainer.get("DepartmentsVO1"); Object str[] = listBindings.getSelectedValues(); for (int i = 0; i < str.length; i++) { System.out.println(str[i]); } } public BindingContainer getBindings() { return BindingContext.getCurrent().getCurrentBindingsEntry(); } }
Save all and run the application. Thus, the ran application is shown below:
Shuttle the Department Name say Administration, Shipping, and Sales
Click on the “Get Selected Value” button. and we can see the Department IDs for the selected Department Name as 10, 50. and 60
Hence, the solution to our requirement.
If you like the post please comment, share, and do join me on Facebook. Please subscribe to my YouTube Channel for video tutorials.
Thanks & Regards,
Susanto Paul
495 total views, 1 views today