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="" 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: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
326 total views, 2 views today