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

Get current date, time , timestamp in Java

You can get the current date time via following two classes – Date and Calendar. And, later use SimpleDateFormat class to convert the date into user friendly format.

-> Date() + SimpleDateFormat()

DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yy HH:mm:ss");
Date date = new Date();
System.out.println(dateFormat.format(date));

-> get the time

Date date = new Date();
System.out.println(date.getTime());

-> get the time stamp

Date date = new Date();
System.out.println(new Timestamp(date.getTime()));

You can define various format i.e

-> dd-MMM-yy HH:mm:ss
-> yyyy/MM/dd HH:mm:ss
-> yy/MM/dd HH:mm:ss

You can use as working code like

import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
 
 
public class GetCurrentDateTime {
  public static void main(String[] args) {
 
	   DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
	   //get current date time with Date()
	   Date date = new Date();
	   System.out.println(dateFormat.format(date));
            
           //get the time
           Date date = new Date();
	   System.out.println(new Timestamp(date.getTime()));

           // get the timestamp
 
  }
}

Get current row of table -Oracle ADF

Requirment- to get the current row of a table

Solution- Following is the code used for this

DCBindingContainer dcb = (DCBindingContainer)getBindings();    
DCIteratorBinding dcItr = dcb .findIteratorBinding("iteratorName");
RowSetIterator rsIter = dcItr .getRowSetIterator();
Row rowObj = rsIter .getCurrentRow();

Happy coding with Vinay Kumar in Techartifact 🙂