Sunday, September 16, 2012

Adding a IN clause to view object using programmatically view criteria

To apply a simple view criteria programmatically to view object you can use the steps from the ADF Developer guide. But when you need to create a view criteria item using IN clause, there is a additional step required. You need to set the min and max cardinality for the view criteria item value.

Below code demonstrates the necessary steps for using the criteria with a IN clause


        ViewObject vo = am.findViewObject("Employees");
        ViewCriteria vc =  vo.createViewCriteria();
        ViewCriteriaRow vcr =  vc.createViewCriteriaRow();
        ViewCriteriaItem vci =vcr.ensureCriteriaItem("EmployeeId");
        vci.setOperator(JboCompOper.OPER_IN);
        vci.setValueMinCardinality(3);
        vci.setValueMaxCardinality(3);
        vci.setValue(0, 101);
        vci.setValue(1, 102);
        vci.setValue(2, 103);
        vc.addRow(vcr);
        vo.applyViewCriteria(vc);

Download the complete example here.

1 comment:

  1. public void setValueMinCardinality(int card)
    For internal use only. Application developers should not use this
    *** For internal framework use in ADS only ***


    There must be another way...

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...