Fri. Apr 23rd, 2021

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="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <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

 240 total views,  2 views today

By Susanto Paul

Susanto is an Oracle ACE, a qualified MCA, MBA, and a highly-skilled Senior Oracle Specialist. He is an enthusiastic Blogger and YouTuber who helps learners to solve their complex problems more efficiently. He has 9+ years of experience in multiple technologies like AWS, Oracle ADF, Oracle APEX, Oracle JET, Oracle VBCS, Oracle IDCS, Oracle PL/SQL, Oracle Integration Cloud, Java, JDBC, Servlets, JSP, Spring, Hibernate, HTML5, CSS3, JavaScript, TypeScript, NodesJS, Angular, MySQL, Oracle WebLogic Server, JUnit, JMeter, Selenium Web Driver, etc. He is a certified: Oracle Certified Professional Java SE 6 Programmer, Oracle ADF 11g Certified Implementation Specialist, Oracle Cloud Platform Application Integration 2020 Certified Specialist, Oracle Cloud Infrastructure Foundations 2020 Certified Associate, and Oracle Cloud Infrastructure Developer 2020 Certified Associate

Leave a Reply

Your email address will not be published. Required fields are marked *