Monday 30 November 2015

how to populate Single or Multiple Selection Lov(List of Values) from Bean in ADF

Hello all,

This shows how we can populate the values of Single or Multiple Selection List of values from Bean.
For this simply create a simple ADF Application.

  1. Then create a Bean with a method public ArrayList<SelectionList> getSelectionListItems();
    package singleselectionlovfrombean.view.bean;
    
    import java.util.ArrayList;
    
    import javax.faces.event.ActionEvent;
    import javax.faces.model.SelectItem;
    
    import oracle.adf.view.rich.component.rich.input.RichSelectManyChoice;
    
    public class TestBean {
        private ArrayList<String> list = new ArrayList<String>();
        private RichSelectManyChoice multSelctBind;
    
        public TestBean() {
            list.add("Second Option");
            list.add("Third Option");
            list.add("Fourth Option");
            list.add("Fifth Option");
        }
    
        public void showSelectedValuesAL(ActionEvent actionEvent) {
            Object object = multSelctBind.getValue();
            System.out.println("Selected Values are : "+object);
        }
    
        public ArrayList<SelectItem> getSelectionListItems() {
            ArrayList<SelectItem> sslist = new ArrayList<SelectItem>();
            for (String s : list) {
                sslist.add(new SelectItem(s, s, s, false));
            }
            return sslist;
        }
    
        public void setMultSelctBind(RichSelectManyChoice multSelctBind) {
            this.multSelctBind = multSelctBind;
        }
    
        public RichSelectManyChoice getMultSelctBind() {
            return multSelctBind;
        }
    }
    
  2. Create a .jspx page and the drag a multiple selection list of Values form component pallet.
  3. This method returns an ArrayList of SelectionList type which we will use for the purpose of showing the values in the list box.

  4. Then select the method returning items by clicking on the Bind


Then press okey.


And Here I also have created a ActionEvent in a button that shows the selected values.

Then run the application.

The pages opens are follows


After the selection click on  Show Selected Values button.



Am attaching the sample application for reference : SingleSelectionLovFromBeanAPP
Please comment for any query or Confusion.

No comments:

Post a Comment