Search Results


Thursday, February 26, 2015

Setting Bind Variables in ADF

In this post we will see some of the ways to programmatically set bind variables in ADF ViewObject.


Setting Value to Bind Variable


The following code sets the value for the the bind variable defined in the whereClause of the ViewObject.

ViewObject viewobj = am.findViewObject(“OrdersVO”);
viewobj.setNamedWhereClauseParam(“BndOrderNumber”, 1001);
viewobj.executeQuery();


Bind Variable in View Criteria


But most often we use ViewCriterias to define the whereClause of the viewObject so that the ViewObject definition could be reused in multiple screens. The following code sets the value for the bind variable defined in the whereClause.

ViewObject vo = getOrdersVO();
ViewCriteria vc = vo.getViewCriteriaManager().getViewCriteria("OrdersViewCriteria");
vc.resetCriteria();
vo.ensureVariableManager().setVariableValue(“BndOrderNumber”, order_number );
vo.applyViewCriteria(vc);
vo.executeQuery();


Dynamic Bind Variable


In some scenarios we would have to set whereClause dynamically. In this case we could create a bind variable on the viewObject and then set its value.

viewobj.setWhereClause(“order_no = :BndOrderNumber”);
viewobj.defineNamedWhereClauseParam(“BndOrderNumber”,null ,null);
viewobj.setNamedWhereClauseParam(“BndOrderNumber”,234)
viewobj.executeQuery();






2 comments :

Muralidhar said...

How to set multiple values like pNo in (1,2,3)

Muralidhar said...

vo.setNamedWhereClauseParam("pEntitId", [1,2,3]); how to apply in clause for this example