Saturday, March 31, 2012

How to programmatically create select one choice

Hi ,

I know it is very easy to create select one choice through ADF-BC .It is just a 1 min job.Just you have to drag and drop the attribute in to page.

But have you ever thinks if you do not have ADF-BC or might you want to create through web service or java class .

In these scenario just you have to create  backing bean which contains following code.



package com.prateek.adf.oracle;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

public class BackingBeanAdf {

      private List<SelectItem> programmaticallyLOV;
    private String selectValue;

       public void setProgrammaticallyLOV(List<SelectItem> programmaticallyLOV) {
        this.programmaticallyLOV = programmaticallyLOV;
    }

    public List<SelectItem> getProgrammaticallyLOV() {
        if(programmaticallyLOV==null){
          programmaticallyLOV = new ArrayList<SelectItem>();
          programmaticallyLOV.add(new SelectItem("SUNDAY", "SUNDAY"));
          programmaticallyLOV.add(new SelectItem("MONDAY", "MONDAY"));
          programmaticallyLOV.add(new SelectItem("TUESDAY", "TUESDAY"));
          programmaticallyLOV.add(new SelectItem("WEDNESDAY", "WEDNESDAY"));
          programmaticallyLOV.add(new SelectItem("THURSDAY", "THURSDAY"));
          programmaticallyLOV.add(new SelectItem("FRIDAY", "FRIDAY"));
          programmaticallyLOV.add(new SelectItem("SATURDAY", "SATURDAY"));
        }
        return programmaticallyLOV;
    }

    public void setSelectValue(String selectValue) {
        this.selectValue = selectValue;
    }

    public String getSelectValue() {
        return selectValue;
    }
}
 


* Select One Choice is accept only Select Item object.So that why in my example backing bean i have just created the List of  Select Item and in  instant block  first i instantiated the List and then i add the value in list which  i want to show on  UI.

For your information i have attached the zip folder of my local project.

http://www.4shared.com/rar/2HWq7C45/CreateLov_2.html


Thanks
Prateek Shaw.

No comments:

Post a Comment