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() ;



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-


<Properties>
                <CustomProperties>
                  <Property
                    Name="renderedMode"
                    Value="Never"/>
                </CustomProperties>
                <SchemaBasedProperties>
                  <DISPLAYHINT
                    Value="Hide"/>
                </SchemaBasedProperties>
              </Properties>




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


<CustomProperties>
                  <Property
                    Name="renderedMode"
                    Value="Never"/>
                </CustomProperties>


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 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 =  


RequestContext.getCurrentInstance().createVisitContext(facesContext,null,


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


        //Annonymous call


        UIXComponent.visitTree(visitContext,facesContext.getViewRoot(),new


VisitCallback(){


            public VisitResult visit(VisitContext context, UIComponent


target)


              {


                  if (table != target)


                  {


                    return VisitResult.ACCEPT;


                  }


                  else if(table == target)


                  {


                      //Here goes the Actual Logic


                      Iterator selection =


table.getSelectedRowKeys().iterator();


                      while (selection.hasNext()) {


                          Object key = selection.next();


                          //store the original key


                          Object origKey = table.getRowKey();


                          try {


                              table.setRowKey(key);


                              Object o = table.getRowData();


                              JUCtrlHierNodeBinding rowData =


(JUCtrlHierNodeBinding)o;


                              Row row = rowData.getRow();


                              System.out.println(row.getAttribute(0));


                          }


                          catch(Exception ex){


                              ex.printStackTrace();


                          }


                          finally {


                              //restore original key


                              table.setRowKey(origKey);


                          }


                      }


                  }


                  return VisitResult.COMPLETE;


              }


        }); 



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)

top.close();

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.

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.

Friday May 21, 2010

ADF Bounded Taskflow Activation

hey guys,
It's really been a while since I last blogged. Just came across a hard-to-debug scenario, so thought of sharing it for the benefit of ADF developers.
I had a page fragment(jsff) wrapped inside a  bounded taskflow, for which the activation was conditional and was based on a requestScope property (be it a requestScope variable or a property coming from a requestScope bean). As soon as the taskflow activates and page renders the requestScope parameters life span ends. After that, when you raise an event inside the page (click of commandLink, moseHover, valueChange event etc) then for the first time the event gets fired but it fails to affect the change in the page, moreover, for the subsequent times the event itself doesn't get fired. Any guesses as to what could be the culprit..?

I guess, I already gave the reason in the initial paragraph. For the first time when the event gets fired, the fwk sees that the page is already lying in inactivate state, so it fails to affect the change and for subsequent times it doesn't even fire the event because it already knew that the page/region is inactive. So, in such a scenario we must use either a pageFlowScope property or transientVO property which could exist till the page's life span.

Saturday Apr 24, 2010

Dynamic Tab Implementation in ADF

Well, this can be a common usecase across apps to open tabs dynamically at runtime based on the request.

Well, in order to achieve this you can have a parent container, lets say a panelTab component.Inside panelTab , u can have a showDetailItem inside an af:foreach or an af:iterator binded to a bean static list which will have as many show detail items as you wish to be shown.

something like this.

private static List = { new showDetailItem("1"),new ShowDetailItem("2") ...};

now in the backing bean you can have a method that takes care of rendering and disclosing an specific tab based on the index.

public void openMyTab(){

List<MyItems> list = refToParentContainer.getChildren();
int indexOfTabToBeOpened = //Write a method that will compute the tab index of the next //tab.

list.get(index).setRendered(true);
list.get(index).setDisclosed(true);

similarly you can set other properties too.

}

Else, instead of having af:foreach/iterator iterating through the SD items , you can go for static SDs in the page with render property set to false and then you can follow the same approach to render/disclose it at runtime.


About

Talk on ADF (Mail To: vijay.x.mohan@oracle.com)

Search

Categories
Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today