Wed. Aug 4th, 2021

Requirement: I have a Shuttle Component where I will select a few Department Names. Now, there is a button with the name “Clear Selected Values“. The moment I click on the “Clear Selected Values” button it should clear all the selected Department Names from the Shuttle Components.

Solution: For solution of the above requirement follow the steps as shown below:

Step 1: Create a sample application for the Shuttle Component, by following the steps as shown in my post “Get Selected Values from a Shuttle Component in Oracle ADF

Step 2: Drag and drop an af:button on the shuttleDemo.jspx page. Set the text=”Clear Selected Values” and actionListener=”#{pageFlowScope.MyBean.clearSelectedShuttleValuesAL}”

Surround the af:selectManyShuttle and the af:button with the af:panelGroupLayout

Also, don’t forget to set the partialTriggers=”b1″ for the af:selectManyShuttle component

Thus, the complete code for the shuttleDemo.jspx 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:panelGroupLayout id="pgl1">
                    <af:selectManyShuttle value="#{bindings.DepartmentsVO1.inputValue}"
                                          label="#{bindings.DepartmentsVO1.label}" id="sms1" partialTriggers="b1">
                        <f:selectItems value="#{bindings.DepartmentsVO1.items}" id="si1"/>
                        <f:validator binding="#{bindings.DepartmentsVO1.validator}"/>
                    </af:selectManyShuttle>
                    <af:button text="Clear Selected Values" id="b1"
                               actionListener="#{pageFlowScope.MyBean.clearSelectedShuttleValuesAL}"/>
                </af:panelGroupLayout>
            </af:form>
        </af:document>
    </f:view>
</jsp:root>

And, the complete code inside MyBean.java class is shown 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 BindingContainer getBindings() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }

    public void clearSelectedShuttleValuesAL(ActionEvent actionEvent) {
        BindingContainer bc = this.getBindings();
        JUCtrlListBinding listBindings = (JUCtrlListBinding) bc.get("DepartmentsVO1");
        listBindings.clearSelectedIndices();
    }
}

Save all and run the application. Thus, the ran application is shown below:

Shuttle few values like Marketing, Purchasing, and Shipping.

Click on the “Clear Selected Values” button and with that, the Shuttle Component’s Selected Values gets Cleared off as shown below.

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

 248 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 *