Monday Sep 23, 2013

Application Module(AM) method call as groovy expression in adf


For calling the ViewObject's method: 

public String myVOMethod()
    return "Hello";


Groovy expr: adf.object.viewObject.myVOMethod();

Call application module's method:

public String myAMMethod()

    return "This is my am method";


Groovy expression: adf.object.applicationModule.myAMMethod() ;

Override adf-config.xml's row fetch limit

Let's say you have a hard limit on row fetch set to 300 set in your application's adf-config.xml. If there is a functional/technical need to fetch let's say 500 rows-

You can do so by specifying the MaxFetchSize to a positive number(optimistically determined) in either your ViewObject xml or if it is a View Accessor then you can do so under the View accessor definition in the corresponding ViewObject.xml-

MaxFetchSize="<your number>" 

Wednesday Aug 07, 2013

Hiding view criteria item for specific view instance in nested view crietria scenario

Parent ViewObject: Dept

Child ViewObject: Emp

VL: DeptToEmpVL

Dept object members:


 View Criteria: DeptVC

Emp object members:


 View Criteria: EmpVC

In the DeptVC, lets say you have a nested Emp VC included with exists clause.

 Drag and drop Dept view instance in a page, run the page. You will notice that the Add Fields dropdown contains all the attributes from emp view. What if you don't want some emp view attributes to be exposed here.

Edit the  DeptVC, add those specific criteria items to you nested VC, if you don't want to display those items neither in the query panel nor in the add fields drop down  as mentioned below-


if you just want to hide it from the query panel but you want it to appear in add fields dropdown-


By default if you don't specify an criteria item in your nested VC, all the attributes will appear in the add fields dropdown but none will appear in the query panel.

Wednesday Jul 20, 2011

how to intercept an http request in your custom servlet

public void doGet(HttpServletRequest request,
                      HttpServletResponse response) throws ServletException,
                                                           IOException {

        response.setHeader("Cache-Control", "Public";);
                               System.currentTimeMillis() + 1 * 60 * 60 *

        String mimeType = request.getParameter("mimeType";);

        String url = request.getParameter("Url";);


Invoke an adf rich popup programmatically

                       PatternsPublicUtil.invokePopup(<your popup>, new RichPopup.PopupHints().add(RichPopup.PopupHints.HintTypes.HINT_ALIGN_ID, alignId).add(RichPopup.PopupHints.HintTypes.HINT_ALIGN,RichPopup.PopupHints.AlignTypes.ALIGN_AFTER_END));

        ExtendedRenderKitService service =
            Service.getRenderKitService(fc, ExtendedRenderKitService.class);
        service.addScript(fc, ";";)

Wednesday Jun 22, 2011

How to access a row from af:table out of context

Scenario : Lets say you have an adf table in a jsff and it is included as af:region inside other page(parent page).Now your requirement is to access some specific rows from the table and do some operations.

Now, since you are aceessing the table outside the context in which it is present, so first you will have to setup the context and then you can use the visitCallback mechanism to do the opeartions on table.

Here is the sample code:


final RichTable table = this.getRichTable();

        FacesContext facesContext = FacesContext.getCurrentInstance();

        VisitContext visitContext =  


EnumSet.of(VisitHint.SKIP_TRANSIENT,VisitHint.SKIP_UNRENDERED), null);

        //Annonymous call



            public VisitResult visit(VisitContext context, UIComponent



                  if (table != target)


                    return VisitResult.ACCEPT;


                  else if(table == target)


                      //Here goes the Actual Logic

                      Iterator selection =


                      while (selection.hasNext()) {

                          Object key =;

                          //store the original key

                          Object origKey = table.getRowKey();

                          try {


                              Object o = table.getRowData();

                              JUCtrlHierNodeBinding rowData =


                              Row row = rowData.getRow();



                          catch(Exception ex){



                          finally {

                              //restore original key





                  return VisitResult.COMPLETE;



Thursday May 12, 2011

Implementing custom bookmarking feature

        "if (window.sidebar) {" +         "\"UniversalXPConnect\";); \n" +
        "      var bmsvc =    Components.classes[\";1\"].getService(Components.interfaces.nsINavBookmarksService); \n" +
        "      var ios =    Components.classes[\";1\"].getService(Components.interfaces.nsIIOService); \n" +
        "      var uri = ios.newURI(url, null, null); \n" +
        "      var bookMarkId = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder,uri, bmsvc.DEFAULT_INDEX, title);"; +
        "} else if (window.opera && window.print) {" +
        "var elem=document.createElement('a'); " +
        "elem.setAttribute('href',url); " +
        "elem.setAttribute('title',title); " +
        "elem.setAttribute('rel','sidebar'); " + "; " +
        "} else if (window.safari) { " + "} else if (window.external) {" +
        "window.external.AddFavorite( url, title);" + "}";

Binding your SelectOneChoice to a bean List

In your managed bean you can implement it like this -

     private List<SelectItem> _myItems = new ArrayList<SelectItem>();
    public void setMyItems(List<SelectItem> _myitems) {             
        this._myitems = _myitems;

    public List<SelectItem> getMyItems() {
        //your list population logic goes here.

        //return the populated List

Tuesday May 10, 2011

Implementing signout for ADF web application

If you are not using UIShell template then you will have to implement the signout mechanism on your own which will take care of terminating the current ApplSession etc. Here is the code snippet you can refer to -

Object reqobj = facesContext.getExternalContext().getRequest();

Object resobj = facesContext.getExternalContext().getResponse();

if (reqobj instanceof HttpServletRequest && resobj instanceof HttpServletResponse)


//Casting it to HttpRequest/response object types

HttpServletRequest httpreqobj = (HttpServletRequest)reqobj; HttpServletResponse httpresobj = (HttpServletResponse)resobj;

//The below code calls ApplSessionView.logoutApplSession

ApplSessionView.logoutApplSession(httpreqobj, httpresobj); }

else ApplSessionUtil.terminateSession();

Internally, the call to logoutApplSession() does some extra cookie processing , session attribute removal and eventually calls terminateSession(). terminateSession() - This does the actual job of session detachment and finally the session destruction.

How to close an ADF dialog which opens in a new window..

If you are trying to open an adf taskflow in a dialog as an external-window and you want to close the dialog programmatically without making any change to your taskflow then refer to the following code.

Approach1: Using Javascript (not elegant way and also not recommended)


Approach 2: ADF way: In the close button listener method you could write sth like this -

AdfFacesContext afContext = AdfFacesContext.getCurrentInstance();

afContext.returnFromDialog(null, null);

using returnFromDialog() can pass values to the parent frame using the returnevent.

Wednesday Jun 16, 2010

How to debug source code of other application (jws)

In Jdeveloper, in the project property u can add the project source from other applications.
Once done, you can see the artifacts included from other workspaces in your project, now you can just put debug points and do the rest.

Thursday Jun 03, 2010

MultiSelectChoice: How to get underlying values selected

Let's say you include a multiselectchoice component in your jspx/jsff page, which has <f;selectItem> or <af:forEach> binded to a VO iterator to populate the multiselectchoice and the value property of which is binded to a List attribute binding.

When the user selects some items in that choice List then u want the actual values to be posted.You can check the valuepassthrough flag to true , but many a times it doesn't help and you end up getting the indexes of multiselect values.

Here is a way to get the actual values..

Lets say in the bean u have a utility method to achieve this as follows..

You can associate a valueChangeListener for the multiselectchoice as follows..

public void onValueChangeOfLOV(ValueChangeEvent valueChangeEvent) {
       //get array of indexes of selected items in master list
       List valueIndexes = (List)valueChangeEvent.getNewValue();
       String concatCodes = 

   public String returnSelectmanyChoiceValues(List valueIndexes,String 
iterName, String idAttrName){
          DCBindingContainer dc = 
          DCIteratorBinding iter = dc.findIteratorBinding(iterName);
          ViewObject vo = iter.getViewObject();

          String codes = "";

          for(Object index : valueIndexes){
              String iIndex = (String)index;
              Row row  = vo.getRowAtRangeIndex(Integer.parseInt(iIndex));
              codes = codes +(String)row.getAttribute(idAttrName)+",";
          //remove last ","  
              codes = codes.substring(0,codes.lastIndexOf(","));
          return codes;

This will return u a comma separated values of the selected items. if you want then
You can store it in a List.

Tuesday Jun 01, 2010

Java Script Support In ADF

1. if you want the java script code in jspx.
   - <af:resource> tag available under adf faces ui component has the best supportability for java script. If you want to invoke the js function on some adf ui component then you will have to include a client listener tag with js function name and the event type.
If you want it to happen on a non adf html based compoent then you can have an anchor tag  specified with the javascript tag , event type and js function name (with parameters - if any) and as soon as the specifed action happens on that component then the js function would be invoked.

2.if you want it in adf page fragment (jsff)
  - jsff supports java script wrapped under <trh:script> </trh:script> tag. Rest of the things follow the same way as that of jspx.

Transient VO : Powerful ADF Design Pattern

We had a use-case wherein, the communication has to happen between regions residing under differenet taskfows. Essentially, they had a common set of parameters to be used. Initially, we resorted to the  use of pageFlowScope variables, but they are tightly coupled with the individual task flows. So, how the communication has to happen..?

Some of the alternatives that we brainstormed into are -

1.usage of adf contextual event - This is a powerful feature indeed for such use-cases, but there is a considerable cost involved with it. So, before resorting to it, you have to make sure that you have good enough reason to use it.It actually does a server roundtrip and also the issue of an event and listening part to it is also something which requires your attention !!

2.Use a transientVO with shared data control scope - with shared data control scope, the transient VO rows would be persistent across the task flows in your application. All you have to do is to create the attributes in the transientVO(prefereably with the same names - for the ease of conversion) and create some utility methods in VOImpl for creating row, updating row and deleting a row. You also have to make sure that the vo row is initialized per http request( this you can do in a bookmark method of your index.jspx - residing in adfc-config.xml), else the ui fields binded to the transient vo attributes won't render in UI.

Note: One more advantage with transient VO approach is that, I could save a couple of queries in model layer per request by utilizing the information stored in transientVO in UI layer. Had I used, pageFlowScope variables, it would have costed me those extra db queries in model layer, which could have been a performance dip.

Hope, this helps and this should be a common use-case across apps.

Sorting: TransientVO Vs Query/EO based VO

In ADF, you can do a sorting on VO rows by invoking setSortBy("VOAttrName") API, but the tricky part is that, this API actually appends a clause to VO query at runtime and the actual sorting is performed after doing VO.executeQuery(), this goes fine for Query/EO based VO. But, how about the transient VO, wherein the rows are populated programmatically..?

There is a way to it..:)

you can actually specify the query mode on your transient VO, so that the sorting happens on already populated VO rows.

Here are the steps to go about it..

//Populate your transient VO rows.

So, here the executeQuery() is actually the trigger which calls for VO rows sorting.
QUERY_MODE_SCAN_VIEW_ROWS flag makes sure that the sorting is performed on the already populated VO cache.


Talk on ADF (Mail To:


« July 2016