Applying Programmatically View Criteria based on Like “%String%” and with IN Clause in Oracle ADF

Use the method below code to apply a view criteria programmatically that has IN clause and Like clause:

        
//Retrieving application module
String filterList="Comma,Separated,List"
ApplicationModule applicationModule =
    Configuration.createRootApplicationModule("","AppModuleLocal");
//retrieving view object

ViewObjectImpl vo =
    (ViewObjectImpl)applicationModule.findViewObject("");
    
//creating a view criteria
ViewCriteria criteria = vo.createViewCriteria();
//creating a view criteria row from criteria to set the condition(ViewCriteriaItem)
ViewCriteriaRow viewRow = criteria.createViewCriteriaRow();

String[] filerItemList = filterList.split(",");

ViewCriteriaItem viewObjectVCRowItem =
    viewRow.ensureCriteriaItem("");
viewObjectVCRowItem.setOperator(JboCompOper.OPER_IN);

for (int i = 0; i < filerItemList.length; i++) {
    viewObjectVCRowItem.setValue(i, filerItemList[i]);
}

ViewCriteriaItem secondVCRowItem =
    viewRow.ensureCriteriaItem("Status");
secondVCRowItem.setOperator(JboCompOper.OPER_LIKE);
    secondVCRowItem.setValue(status);
criteria.addElement(viewRow);
vo.applyViewCriteria(criteria);
vo.executeQuery();

Further manipulations can be done accordingly.

 Courtesy: Krishna Reddy Tumati

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.