Most Used Codes in ADF (Iterate over ViewObject, get Value from pageFlow Scope variable)

Sharing is Caring

Here I have written some piece of most used codes in ADF. While working on the framework you’ll need that regularly.

Iterate Over View Object-

Sometimes we need to iterate in the table to check for some validation like we have to check for the duplicate record or we want to delete all data of the table with one click then we have to get all rows of table– this is a very common use case in ADF, so you can use the following snippet of code to do this

1. Using AllRowInRange method to get rows available in the range

ViewObject vo=am.getViewObject();

// Get All Rows in range of ViewObject in an Array
Row[] rArray=vo.getAllRowsInRange();

//Loop over array of Rows
for(Row r:rArray){

/*your operation code*/

}

2. Using RowSetIterator-

ViewObject vo = this.getViewObject();

//Create RowSetIterator
RowSetIterator rsi = vo.createRowSetIterator(null);
//Iterate Over this to get all rows
while (rsi.hasNext()) {
Row nextRow = rsi.next();
//Put additional code here
}
rsi.closeRowSetIterator();

Get Value from the task flow parameter(Using pageFlow Scope)-

We can get value from Taskflow parameter using page flow scope and can use it in Our Bean.
Suppose we have defined a parameter in the page to pass Session_Id.
We can get it using pageflow scope

Integer sessionId = Integer.parseInt(resolvEl(“#{pageFlowScope.Session_Id}”));

 Code For resolvEl-

    public String resolvEl(String data) {
        FacesContext fc = FacesContext.getCurrentInstance();
        Application app = fc.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = fc.getELContext();
        ValueExpression valueExp = elFactory.createValueExpression(elContext, data, Object.class);
        String Message = valueExp.getValue(elContext).toString();
        return Message;
    }

 

Related Posts

An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF

4 thoughts on “Most Used Codes in ADF (Iterate over ViewObject, get Value from pageFlow Scope variable)”

  1. You ɑctually make іt seem ѕo easy with your presentation but I find this topic to be reɑlly something that I think I
    ԝould neνer understand. It seems too compliϲated and extremely broad for me.
    I’m looking forԝard for your neхt post, I wiⅼl try to ցet the hang of іt!

Leave a Reply

Your email address will not be published. Required fields are marked *