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

Difference between HashSet and TreeSet in Java | Techartifact

HashSet:

– Class offers constant time performance for the basic operations (add, remove, contains and size).
– It does not guarantee that the order of elements will remain constant over time
– Iteration performance depends on the initial capacity and the load factor of the HashSet.
– It’s quite safe to accept default load factor but you may want to specify an initial capacity that’s about twice the size to which you expect the set to grow.
– The underlying data structure is Hashtable
– Heterogeneous objects are allowed
– Insertion order is not preserved and it is based on hashcode of the objects.
– null insertion is possible.

TreeSet:

– TreeSet class has a member reference variable of type NavigableMap. In fact, TreeSet make use of unique key property of Map’s to ensure no duplicate elements. There is a dummy value used for this instance member variable .
-The underlying data structure is balanced tree.
– Guarantees log(n) time cost for the basic operations (add, remove and contains)
– Heterogeneous objects are not allowed by defalut.
– Insertion order is not preserved and all the objects are inserted according to some sorting order.
– As the first element only null insertion is possible and in all other cases we will get NullPointerException (After null insertion other insertion not possible)
– Guarantees that elements of set will be sorted (ascending, natural, or the one specified by you via it’s constructor)
– Doesn’t offer any tuning parameters for iteration performance
– Offers a few handy methods to deal with the ordered set like first(), last(), headSet(), and tailSet() etc
– we can construct a constructor your own rules for what the order should be using a comparable or comparator.

The TreeSet implementations useful when you need to extract elements from a collection in a sorted manner. It is generally faster to add elements to the HasSet then convert the collection to a TreeeSet for sorted traversal.

To optimize HashSet space usage , you can tune initial capacity and load factor. TreeSet has no tuning options, as the tree is always balanced, ensuring log(n0 performance for insertions, deletions and queries.

get object of ApplicationModule in managed bean in ADF | Techartifact

Requirment- Need an object of Application module in managed bean

Sometime we required to get an object of ApplicationModule in managed bean.May be we want to play with some VO object which we can get from
ApplicationModuleImpl Object only.

There are two ways.

First way-

        FacesContext context = FacesContext.getCurrentInstance();
        BindingContext bindingContext = BindingContext.getCurrent();
        DCDataControl dc  = bindingContext.findDataControl("AppModuleAMDataControl"); // Name of application module in datacontrolBinding.cpx
        AppModuleAMImpl appM = (AppModuleAMImpl)dc.getDataProvider();
     

Above AppModuleAMDataControl is name of application module in datacontrolBinding.cpx,open datacontrol and check the ID in tag. See below for reference.

 <BC4JDataControl id="AppModuleAMDataControl" Package="oper.model.module"
                     FactoryClass="oracle.adf.model.bc4j.DataControlFactoryImpl" SupportsTransactions="true"
                     SupportsFindMode="true" SupportsRangesize="true" SupportsResetState="true"
                     SupportsSortCollection="true" Configuration="AppModuleAMLocalWeb" syncMode="Immediate"
                     xmlns="http://xmlns.oracle.com/adfm/datacontrol"/>

Now you got the application module you can get the object of any ViewObjectImpl.

Second Way-

You can get the object of applicationModuleImpl by writing this line-

AppModuleAMImpl am = (AppModuleAMImpl)resolvElDC(AppModuleAMDataControl)

resolvElDC method is described below


private Object resolvElDC(String data) {
        FacesContext fc = FacesContext.getCurrentInstance();
        Application app = fc.getApplication();
        ExpressionFactory elFactory = app.getExpressionFactory();
        ELContext elContext = fc.getELContext();
        ValueExpression valueExp =
            elFactory.createValueExpression(elContext, #{data. + data + .dataProvider}, Object.class);
        return valueExp.getValue(elContext);
    }

Happy coding with Techartifact . 🙂