Please disable your adblock and script blockers to view this page

Search this blog

Wednesday 21 November 2012

Shuttle Component in Oracle ADF (Allow Multiple Selection), Get Selected values from Shuttle Component



Hello All

Hope you all are doing well :) 

Shuttle component supports multiple selections at Runtime, when we need to select multiple records at runtime then we can use Shuttle Component.

Now we see how to use shuttle component (af:selectManyShuttle) in Oracle ADF

Shuttle Component in Oracle ADF

Follow these steps-

  • Prepare model for Employees table of HR Schema(Create EO,VO and AM)
  • Now drag Employees ViewObject from DataControl to page and select multiple selection-->ADF Select Many Shuttle-
Drop ViewObject as ADF Select Many Shuttle






  • Now edit binding for this Shuttle Component, choose attribute that you want to show and also base attribute-
    Edit Shuttle binding and select base and display attribute

     
  • Now it will look like this, drag a button to get selected attribute of this shuttle component
    af:selectManyShuttle
     
    Now write code on button's actionEvent to get selected value from Shuttle-


    import oracle.adf.model.BindingContext;
    import oracle.binding.BindingContainer;
    
        /*****Generic Method to get BindingContainer of current page, fragment or region**/
        public BindingContainer getBindingsCont() {
            return BindingContext.getCurrent().getCurrentBindingsEntry();
        }
    

     public void getSelectedValue(ActionEvent actionEvent) {
          //Get Binding Continer of Page
            BindingContainer bc = this.getBindingsCont();
         //Get shuttle binding from pagedef
            JUCtrlListBinding listBindings = (JUCtrlListBinding)bc.get("Employees1");
        //Get Selected Values
            Object str[] = listBindings.getSelectedValues();
        //Iterate over selected values
            for (int i = 0; i < str.length; i++) {
                System.out.println(str[i]);
            }
        }
    

    When you run this it should look like this and your Shuttle is ready
    Get selected value of shuttle component ADF

8 comments :

  1. can i put more than one value in the selected value ..like empid&deptid

    ReplyDelete
    Replies
    1. No you can not, you can get other values using base value of component

      Delete
  2. Hi Ashish
    the result of System.out.println(str[i]); got first name only
    i want to obtain first name and last name
    thanks

    ReplyDelete
    Replies
    1. You can get other values by using base value to filter viewObject

      Delete
  3. guys my view object has parameter which is sent in the login page, just before the shuttle page appears but the shuttle is always empty unless i remove the query parameters and get a fixed query the shuttle works.....
    please help me

    ReplyDelete
    Replies
    1. Check that bind variables values is setting properly , Check ViewObject rowcount

      Delete
    2. This comment has been removed by the author.

      Delete
  4. now i get this error!!
    The number of items selected for shuttle: sms1 exceeds the total number of items in the shuttle. No selected items.
    please help

    ReplyDelete