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….

Get the current node of a tree table in Oracle ADF | Techartifact

Requirement- To get the current current node of tree table and get value of that node.

Solution- we will get the rowKeySet of the treetable.The using findNodeByKeyPath method , we will get the selected node.I already posted to get selected row of tree

RowKeySet selectedRows = treeTable.getSelectedRowKeys();
//use EL to access binding (note that you can do this in Java as well)
JUCtrlHierBinding treeTableBinding = (JUCtrlHierBinding) executeValueExpression("#{bindings.<tree binding name>}");  
//get first entry of selected rows (single selection case)
JUCtrlHierNodeBinding node =  treeTableBinding .findNodeByKeyPath((List)selectedRows .iterator().next());
... do the work with the node here ...

private Object executeValueExpression(String valueExpression){
      FacesContext fctx = FacesContext.getCurrentInstance();
      ELContext elctx = fctx.getELContext();
      Application app = fctx.getApplication();
      ExpressionFactory exprFactory = app.getExpressionFactory();
      ValueExpression valueExpr = exprFactory.createValueExpression(
                                elctx,
                                valueExpression,
                                Object.class);
       return valueExpr.getValue(elctx);
      }

Happy coding with Vinay Kumar in Techartifact