While developing VO hierarchy for generic applications recently i faced issue while trying to filter a Child VO at runtime.
1. View Link option:
First option that came to mind is to add the additional where clause in View Link, This works fine But makes the VO tree specific to your need and it doesn't remain generic.
2. Fetching Parent VO property in childVO and setting VC in executeQueryForCollection :
ApplicationModule am= this.getApplicationModule();
ViewObject vo = am2.findViewObject("ParentView1");
prop = (String)vo.getProperty("Parent_prop");
if(propVo_prop.equals("Y"))
this.setApplyViewCriteriaName("VC");
super.executeQueryForCollection(object, object2, i);
This is not recommended ADF coding.
3. The correct way to do this in Parent VO , fetch Child VO from View Link and set the VC:
Method in parent VO/executeQueryForCollection
Row r = getCurrentRow();
if (r != null) {
RowSet rs = (RowSet)r.getAttribute("ChildView");
if (rs != null) {
ViewObject accessorVO = rs.getViewObject();
accessorVO.ensureVariableManager();
accessorVO.getVariableManager().setVariableValue( "Param", value);
ViewCriteriaManager vcm = accessorVO.getViewCriteriaManager();
ViewCriteria vc = vcm.getViewCriteria("QueryByParam");
accessorVO.applyViewCriteria(vc); }
executeQuery();
For details : http://www.oracle.com/technetwork/developer-tools/adf/learnmore/feb2011-otn-harvest-328207.pdf
This works !!
No comments:
Post a Comment