Tag Archives: snippets

How To in Jdeveloper ADF – To call a VO from another VO or from AM method

How to set an Attribute value from one VO into another VO?


//in you Application module Impl file have the follwing code written inside the method which will set the value for another vo
//lets say UploadView is the View object that you would want to set the value
ViewObject vo = findViewObject("tUploadView");
//if its not in Application Module, you will have to get the VO instance either from iterator if you are using this code in the bean
//get the rowset of UploadView
RowSet rs = vo.getRowSet();
//iterate through
//get the row
Row r = rs.next();
//set the value
r.setAttribute("ValueItem", value); //ValueItem is the Attribute that you want to set

How To in Jdeveloper ADF Tutorials- reset the inputText component values

Sometimes the value of the inputText component is not refreshed and the value that was previously entered will still persist within the component. To overcome this issue. we have to use the resetValue() method to reset the component value and display the components intial state

What it does:

  • Get handle to the inputText component using the JSFUtils find component method with the inputText id passed as a parameter
  • set the submitted value of the inputText as null
  • reset’s the input component value
  • refresh the component
private void resetInputText(String id) { 
RichInputText input = (RichInputText)JSFUtils.findComponentInRoot(id); 


This method is used to reset the inputText component value’s in a popup, af:formlayout, af:table.

How To in Jdeveloper ADF Tutorials – get the selected table rows

This is a useful handy code to get the selected rows for the table.

What it does:

  • Get handle to the table using the JSFUtils find component method with the table id passed as a parameter
  • Get the selectedRowKeys for the table
  • Iterate through the rowkeys
  • Get the rowkey from the iterator
  • Add the rowkeys into a list
  • return the list to the caller

This method takes the table id as the parameter

private List getSelectedList(String tableName) {
RichTable rt = (RichTable)JSFUtils.findComponentInRoot(tableName);
RowKeySet keySet = rt.getSelectedRowKeys();
Iterator iter = keySet.iterator();
iter = keySet.iterator();
List list = new ArrayList();
while (iter.hasNext()) {
return list;


This method is used to check if any rows are selected for the particular table. The method returns the rowkeys of the rows selected if there are any rows selected for the table

Snippet to check if the transaction is dirty

We can use the following code snippet to check if the transaction is dirty or not

BindingContext bctx = oracle.adf.controller.binding.BindingUtils.getBindingContext();
if (bctx.findDataControlFrame(bctx.getCurrentDataControlFrame()).isTransactionDirty()) {
 //show the timestamp
 //don't show

Ways to set the Query Mode programatically

The following snippet will be helpful in setting up the mode of the query criteria in programmatic way.

public Boolean setAdvancedMode(){
              QueryDescriptor descriptor =
             return true;

public Object evaluateEL(String el) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();
        ExpressionFactory expressionFactory =
        ValueExpression exp =
            expressionFactory.createValueExpression(elContext, el,
       return exp.getValue(elContext);

Easiest way to get the current binding from the bean

use the following snippet to get the current binding

BindingContainer bindings =  BindingContext.getCurrent().getCurrentBindingsEntry();
 AttributeBinding at = (AttributeBinding)bindings.getControlBinding("Period");

The above mentioned code is useful only in case of retrieving values of any attribute binding in the page definition file. To retrieve specific information use it like

//For search binding use it like
FacesCtrlSearchBinding fc =
FacesCtrlSearchBinding fc =

//For LOV binding use it like
FacesCtrlLOVBinding fc = (FacesCtrlLOVBinding)bindings.get("PeriodLOV");

some of the useful methods that can also be used for retrieving binding is

private BindingContainer getBindings() {
BindingContainer bindings =
(BindingContainer)fc.getApplication().evaluateExpressionGet(fc, "#{bindings}",
return (bindings == null) ? null : bindings;

to retrieve the bindings  or executable you use it like

//to retireve the tree/table bindings
FacesCtrlHierBinding fc = (FacesCtrlHierBinding)bindings.get("Period");

//to retireve the tree/table iterator
DCIteratorBinding dc = (DCIteratorBinding)bindings.get("PeriodIterator");

Javascript code to fire the event

The following function can be called using the af:clientListener on any event

function showMenu(event){
 var adfRichMenu = event.getSource();


Scroll to specific row in a table on pageload

Following code will help you to scroll to a specific row in a af:table on page load.

//Code to scroll to a specific row
RowKeySet ps = this.tableBinding.getSelectedRowKeys();

Also set the displayRow=selected for the table

How to iterate the showDetailItem inside the panelTabbed component using af:forEach

Here is the code

       private List items;
       private ArrayList list = new ArrayList();

        public Bean(){
            list.add(new SelectItem("1"));
            list.add(new SelectItem("2"));

         public List getItems() {
             return list;
<panelTabbed id="pt1">
 <forEach var="row" items="#{Bean.items}">
 <showDetailItem text="showDetailItem #{row.label}" id="sdi1" />

and it renders like

How to hide the viewcriteria from the af:query panel

If you want to hide the view criteria, then here is the easy way
The code is written in the setter of the af:query binding

public void setQuery_binding(RichQuery query_binding) {

 this.query_binding = query_binding;

 DCBindingContainer bindings = (DCBindingContainer)this.getBindings();
 DCIteratorBinding iter =

 ViewObjectImpl voimpl = (ViewObjectImpl)iter.getViewObject();
 ViewCriteria vc =  voimpl.getViewCriteriaManager().getViewCriteria("");
 vc.setProperty(ViewCriteriaHints.CRITERIA_SHOW_IN_LIST, ViewCriteriaHints.CRITERIA_HINT_FALSE);

  • getting the handle to the iterator
  • getting handle to the ViewCriteriaManager, and then getting handle to the specific view criteria that we wanted to hide
  • modifying the ViewCriteriaHints.CRITERIA_SHOW_IN_LIST property to false

note: helper method – getBindings()

 private BindingContainer getBindings() {
 if (this.bindings == null) {
 FacesContext fc = FacesContext.getCurrentInstance();
 this.bindings =
 return this.bindings;