Sunday, November 06, 2016

OAF -How to get the current page name

OAF - CO Extension - Find the page name at run time.

I have come across a requirement for which i have to perform CO extension.

But there are two pages involved in which both of them are using same CO.

But i have to write a different logic for the pages.

So i have used the below logic to identify the page and wrote the logic accordingly.


Hope the below code helps..


//Code to get the page Name.


    String pageURL = pageContext.getCurrentUrl ();
    int lastIndex  = pageURL.lastIndexOf( '/' );;
    String finalPageNameStr = pageURL.substring(lastIndex + 1, pageURL.indexOf("&"));
    pageContext.writeDiagnostics(this,"Final Page Name -->" + finalPageNameStr,1);



  if (finalPageNameStr!=null && "pageNameA".equals(finalPageNameStr))
    {
 pageContext.writeDiagnostics(this," Inside Page A logic ",1);

}
 else  if (finalPageNameStr!=null && "pageNameB".equals(finalPageNameStr))
   {
  pageContext.writeDiagnostics(this," Inside Page B logic ",1);  
}







Post a Comment