Get value of the outputtext in javascript and access to backing bean in Oracle ADF

Requirement -Get value of the outputtext in javascript and send it to backing bean in Oracle ADF
Solution – We will use clientListener to call java script function and Serverlistener for calling java function

Below is the code for accomplish this

– page code

    <af:outputText value="value outputText" id="ot32" clientComponent="true"
                    shortDesc="shortDesc">
        <af:clientListener type="mouseOver"
                method="customJsFunction"/>
        <af:serverListener type="mycustomserverEvent" method="#{OutputTextCase11.handleServerEvent}"/>                
    </af:outputText>
    <br></br>
    <af:outputText value="Init" shortDesc="shortDesc" id="ot1" clientComponent="true"/>
 

– find javascript function code

   var customJsFunction = function(event)
   {
      var exceptiondata = event.getSource().findComponent("ot32").getValue();
      AdfCustomEvent.queue(event.getSource(),
                       "mycustomserverEvent",
                       {param1:exceptiondata},
                       true);
      return true;
   }
 

– method in bean

  public void handleServerEvent(ClientEvent ce)
  {
    String param = (String)ce.getParameters().get("param1");
    RichOutputText outputText=(RichOutputText)ce.getComponent().findComponent("ot1");
    outputText.setShortDesc(param);
    outputText.setValue(param);
    AdfFacesContext.getCurrentInstance().addPartialTarget(outputText);
  }
 

happy coding with Vinay in 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