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.
2. put this code in the getter method.
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.
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) {use javax.faces.model.SelectItem;
this.al = al;
}
public ArrayList<SelectItem> getAl() {
return al;
}
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 :)