Iterate Over View Object-
Some times we need to iterate in table to check for some validation as we have to check for duplicate record, we want to delete all data of 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 following snippet of code to do this
1. Using AllRowInRange method to get rows available in 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(); } rsi.closeRowSetIterator();
Get Value from taskFlow parameter(Using pageFlow Scope)-
we can get value from TaskFlow parameter using pageflow scope and can use it in Our Bean.
Suppose we have defined a parameter in page to pass Session_Id.
We can get it using pageflow scope
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;
}
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;
}
Ashsish, the first method using the AllRowInRange should not be used. Think about what happens if the table has >100000 rows!
ReplyDeleteTimo
Hi Timo
DeleteThanks for pointing , Can we use this for less number of rows ?
Ashish