Monday, August 29, 2011

Call multiple URLs on single click of af:goLink in Oracle ADF

Hi,

Last week i experienced a challenging task to forcefully logout from UCM when user logouts from WebCenter application without using Single Sign-on solution.

Note that the application was Extended WebCenter Spaces 11g PS2 so there was no other alternate solution for current environment. i will cover the whole topic in different post sometime soon.

In this post i will cover a simple tip how to call multiple URLs on a single click of af:goLink component in Oracle ADF.

Solution:

I created a simple JavaScript function to call a URL

   1: <af:resource type="javascript">
   2:     function LogoutFromUCM(){    
   3:       hostname = window.location.hostname;
   4:       document.location.href="http://"+ hostname + "/cs/logout.htm";
   5: </af:resource> 

Later call that JavaScript method on af:goLink using af:clientListener



   1: <af:goLink text="Logout"
   2:            id="logoutLink" 
   3:            inlineStyle="white-space:nowrap"
   4:            rendered="#{security.authenticated}"
   5:            shortDesc="Click here to logout"
   6:            destination="/adfAuthentication?logout=true&amp;end_url=/webcenter/faces/custom/oracle/webcenter/webcenterapp/view/templates/LogoutPage.jspx">
   7:   <af:clientListener method="LogoutFromUCM" type="mouseUp"/>
   8: </af:goLink>
The Destination attribute of af:goLink is calling a logout for WebCenter application and method attribute in af:clientListener is calling a JavaScript function to perform logout from UCM.



Using similar technique you can open any URL in a popup as well.


Hope you like this,


Zeeshan Baig

No comments:

Post a Comment