A ViewObject can be defined with multiple ViewCriterias having multiple Criteria Items within it.
For a ViewObject consumer to execute it with a specific ViewCriteria programmatically, below is the code assuming "am" is the Application Module instance.
ViewObject pVO = _am.findViewObject("OrgOrganizationDefinitionsSecuredP1");
if(pVO != null){
ViewCriteriaManager vcm = pVO.getViewCriteriaManager();
ViewCriteria vc = vcm.getViewCriteria("myCriteria");
ViewCriteria dsvc = vcm.getViewCriteria("getDSBackedOrgs");
ViewCriteriaRow vcr = vc.createViewCriteriaRow();
vcr.setAttribute("MasterOrgFlag", "= Y");
vcr.setConjunction(ViewCriteriaRow.VC_CONJ_AND);
vc.add(vcr);
ViewCriteriaRow vcr1 = (ViewCriteriaRow)vc.createViewCriteriaRow();
vcr1.setAttribute("OrganizationCode", "= V1");
vcr1.setConjunction(ViewCriteriaRow.VC_CONJ_AND);
vc.add(vcr1);
pVO.applyViewCriteria(vc);
pVO.applyViewCriteria(dsvc,true);
pVO.executeQuery();
}
The above piece of code programmatically applies a view criteria of my choice among the list of view criterias defined for the view object. It programmatically adds criteria rows to it. Each criteria row can have multiple criteria items and each such item corresponds to one where condition in SQL Where clause. The setAttribute method on ViewCriteriaRow defines a criteria item here.
Another important finding in the above code is the way to apply multiple criterias to a view object. The applyViewCriteria(<ViewCriteriaName>) method clears of the existing list of applied view criterias and applies the current one. The applyViewCriteria(<ViewCriteriaName>, true) appends the current view criteria to the existing list.
For a ViewObject consumer to execute it with a specific ViewCriteria programmatically, below is the code assuming "am" is the Application Module instance.
ViewObject pVO = _am.findViewObject("OrgOrganizationDefinitionsSecuredP1");
if(pVO != null){
ViewCriteriaManager vcm = pVO.getViewCriteriaManager();
ViewCriteria vc = vcm.getViewCriteria("myCriteria");
ViewCriteria dsvc = vcm.getViewCriteria("getDSBackedOrgs");
ViewCriteriaRow vcr = vc.createViewCriteriaRow();
vcr.setAttribute("MasterOrgFlag", "= Y");
vcr.setConjunction(ViewCriteriaRow.VC_CONJ_AND);
vc.add(vcr);
ViewCriteriaRow vcr1 = (ViewCriteriaRow)vc.createViewCriteriaRow();
vcr1.setAttribute("OrganizationCode", "= V1");
vcr1.setConjunction(ViewCriteriaRow.VC_CONJ_AND);
vc.add(vcr1);
pVO.applyViewCriteria(vc);
pVO.applyViewCriteria(dsvc,true);
pVO.executeQuery();
}
The above piece of code programmatically applies a view criteria of my choice among the list of view criterias defined for the view object. It programmatically adds criteria rows to it. Each criteria row can have multiple criteria items and each such item corresponds to one where condition in SQL Where clause. The setAttribute method on ViewCriteriaRow defines a criteria item here.
Another important finding in the above code is the way to apply multiple criterias to a view object. The applyViewCriteria(<ViewCriteriaName>) method clears of the existing list of applied view criterias and applies the current one. The applyViewCriteria(<ViewCriteriaName>, true) appends the current view criteria to the existing list.
Hi, I wrote some custom code and exposed them to the VO client, The method appears in the data control. Now, I can use the method when i drag and drop to the page as a button, and I can successfully apply view criteria .
ReplyDeleteNow I have problem applying the same in Customisation mode, when I drag drop the button to page, no binding window appears and I am not able to pass the parameter to the Java code. Please guide.
Hi, I wrote some custom code and exposed them to the VO client, The method appears in the data control. Now, I can use the method when i drag and drop to the page as a button, and I can successfully apply view criteria .
ReplyDeleteNow I have problem applying the same in Customisation mode, when I drag drop the button to page, no binding window appears and I am not able to pass the parameter to the Java code. Please guide.
Thanks for the note on applyViewCriteria(viewCriteria, boolean)! it's very useful.
ReplyDeleteis it possible to add an AND Conjunction for the same ViewCriteriaItem? like "age >= 20 and age <=60"