Alternative way to fetch VO attribute using selected in index of LOV

If you have access to the index of the selected item, then you can use value to retrieve value of any attribute of the underlying view object.

I agree that with new releases there are more direct approaches in doing so, however, depending on the business requirement, the following method may just come handy –

    public int getValue(int index){
        
        int value = 0;
        
        ViewObject vo = this.findViewObject(<View Object>);
        Row r = vo.getRowAtRangeIndex(index);
        
        try{
            value = Integer.parseInt(r.getAttribute(<Attribute Name>).toString());
        }catch(NullPointerException npe){
            value = 0;
        }
        return value;
        
    

Author- Ankit Gupta

Happy coding with Techartifact….

Changing the WHERE clause or VO Query at runtime in Oracle ADF

Requirement- To change the WHERE clause of a query at run time:

Create a String containing the new WHERE clause. Do not include the word “WHERE”. If you do want to remove the WHERE clause entirely, use null. For example, either of the following could be appropriate definitions:

Pass this string into setWhereClause(). For example, if OrdVO is a variable containing the view object instance to be changed, you would call:

String whereClause = “ORDER_TOTAL > 500”;
String whereClause = null;
ordVO.setWhereClause(whereClause);

You can write this method in AmImpl.Java.For example

    public void executeSearchInstanceNoExp(String instanceNo) {
    String whereClause="instance_status = 'EXPIRED'";
    ViewObjectImpl searchVO = this.getEmployeeVo(); //relaventVO
    searchVO.setWhereClause(whereClause);
    searchVO.executeQuery(); //executeVO with Criteria

    }

you can add ORDER BY clauses of a query at runtime by calling setOrderByClause() on the view object.

String orderByClause = "ORDER_TOTAL";
ordVO.setOrderByClause(orderByClause);

Change the VO query at runtime or changing the Table or view at runtime

createViewObjectFromQueryStmt is used to change the query .You can write this method in AmImpl.Java

    public void executeSearchVoExp() {
       String sqlStatement= "select * from EMP";
        ViewObject dynamicVO = this.findViewObject("SearchByCustomerVo1");  
        dynamicVO.remove();  
        dynamicVO = this.createViewObjectFromQueryStmt("SearchByCustomerVo1", sqlStatement);  
        dynamicVO.executeQuery(); //executeVO with Criteria

    }