Saturday, March 31, 2012

How to programmatically populate af:table

Hi ,

It is same as mine last post.it is very easy to create the af:table through  ADF-BC.If you want to learn more about af:table then see the link http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_table.html for more information.

af:table has one  attribute value which  will accept the List or Collection Model value  to render the table.so i have just create a backing bean and where i have created the List of Example object which will render in UI as table.whatever attribute is present in  Example class it will render as a individual column.


package com.prateek.oracle.adf;

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


public class BackingBean {
private List exmapleObjectList;

{
exmapleObjectList = new ArrayList();
ExmapleObject ex1 = new ExmapleObject();
ex1.setId("1");
ex1.setEFirstName("prateek1");
ex1.setELastName("Shaw1");
ex1.setEAddress("hyderabad1");
ExmapleObject ex2 = new ExmapleObject();
ex2.setId("2");
ex2.setEFirstName("prateek2");
ex2.setELastName("Shaw2");
ex2.setEAddress("hyderabad2");
ExmapleObject ex3 = new ExmapleObject();
ex3.setId("3");
ex3.setEFirstName("prateek3");
ex3.setELastName("Shaw3");
ex3.setEAddress("hyderabad3");
ExmapleObject ex4 = new ExmapleObject();
ex4.setId("4");
ex4.setEFirstName("prateek4");
ex4.setELastName("Shaw4");
ex4.setEAddress("hyderabad4");
exmapleObjectList.add(ex1);
exmapleObjectList.add(ex2);
exmapleObjectList.add(ex3);
exmapleObjectList.add(ex4);

}


public void setExmapleObjectList(List exmapleObjectList) {
this.exmapleObjectList = exmapleObjectList;
}

public List getExmapleObjectList() {
return exmapleObjectList;
}
}


open the following the link to download sample project

http://www.4shared.com/rar/WVdPSfSh/AdfTable.html

Thanks
Prateek

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.