Showing posts with label bean value in select one choice. Show all posts
Showing posts with label bean value in select one choice. Show all posts

Tuesday 9 December 2014

Populate Data to Select One Choice from Bean

Hello Fellas,
Today I'm Sharing my learning to how to populate data to select one choice Programitically

Steps Involded

1. In the managed bean create a property and make its accessor and mutators.
private ArrayList<SelectItem> al=new ArrayList<SelectItem>();
    public void setAl(ArrayList<SelectItem> al) {
        this.al = al;
    }
    public ArrayList<SelectItem> getAl() {
        return al;
    } 
             use javax.faces.model.SelectItem;

2.  put this code in the getter method.
    public ArrayList<SelectItem> getAl() {
        al.add(new SelectItem("x1","India"));
        al.add(new SelectItem("x2","China"));
        al.add(new SelectItem("x3","Sri Lanka"));
        al.add(new SelectItem("x4","Japan"));
        return al;
    }

3 select the component i.e. select one choice  on the page, use it's selectItems component,
   use its value field,  and put this code there.
 <f:selectItems  id="si2" value="#{XBean.al}"/>

Bean


jspx



thank you :)


A Guide to Installing Oracle HR Schema on an Existing Docker Container

  Hi Reader, Today I want to share my learning on how to install Oracle HR schema on a existing docker container. Step 1: Download the verif...