Wednesday, September 29, 2010

HideShowHeader bean and the setDefaultDisclosed property

Today's exercise will focus on one and only one property available to you in JDeveloper. This property is called the "setDefaultDisclosed" property and it controls whether a HideShowHeader region is expanded or collapsed. When you setup a pageLayout and associated regions this is set declaratively. That is, you set a property which controls how it is displayed on the page and you never worry about it again. The users have free regin to toggle it all they want.

However, suppose Oracle provides a HideShowHeaderRN on a page that is closed by default and you would like this to be expanded by default. If you struggle to think of an example of this, I've taken the liberty of providing one from Self Service Human Resources. Complete any of the Manager Self Service functions and hit the Review page. The list of approvers will be listed at the bottom of the page (if you configured AME correctly) and you have the option of adding an Ad Hoc approver:



As you can see it defaults to the collapsed state. Suppose you would like to auto-expand this when the page loads. Here is the expanded state that you'd like to see by default:


In the interest of time, we're going to skip the fundamentals on how to extend a Controller .class (CO) file in Oracle Applications. End-to-end steps on how to perform a CO extension be found in the following articles:

Controller class extension in 11.5.10
Controller class extension in R12

For our purposes, it is enough to know that programmatically setting a property on a web bean inside Oracle Applications occurs inside a Controller .class. We'll still need to know which of the COs to extend, so start by clicking the "About this Page" link in the lower left corner of the page. If you don't have that, set the profile option FND: Diagnostics for your user, clear the cache and then rejoin us. Be sure to click "Expand All" when you get to the page:



Scroll down until you see the Approval region. We'll start with the ApprovalsCO file:


To see where this file is stored in Oracle, expand the Business Component References Details hide/show item:


The complete path is oracle.apps.ame.dynamicapprovals.webui.ApprovalsCO:


This will be important as we will be importing and then extending this delivered code inside JDeveloper.

We will do the following:
  1. Import the page with the approvals section into JDeveloper
  2. Set a new controller class for the Region that extends the delivered CO
  3. set the setDefaultDisclosed property of the HideShowHeader region
Download the page definition of from the database using jdr_utils.printDocument. You'll want to start with the Review page that all SSHR transactions use and repeat the procedure until you get to the approvals section:


set feedback off
set serveroutput on format wrapped
set linesize 100
spool hack.lst
--
execute jdr_utils.printDocument('/oracle/apps/per/selfservice/review/webui/ReviewPG',100);
--
spool off


After studying the output from the above command, notice the /oracle/apps/ame/dynamicapprovals/webui/ApproversRN:


Re-run the jdr_utils.printDocument command and save the output in C:\jdevoafr12\myprojects\oracle\apps\ame\dynamicapprovals\webui\ApproversRN.xml where jdevoafr12 is the home where you installed JDeveloper for R12.

Inside JDeveloper, File -> Import -> Java Source to import the page definition. Once it appears, click it, then drop down into the structure and highlight the area region where you'd like to assign a new Controller. Naturally, I will use the prefix "hack" for my package: hack.oracle.apps.ame.dynamicapprovals.webui and hackApprovalsCO for the file name:


Here is the extended Controller .class file with comments inline:


/*===========================================================================+
| Copyright (c) 2001, 2005 Oracle Corporation, Redwood Shores, CA, USA |
| All rights reserved. |
+===========================================================================+
| HISTORY |
+===========================================================================*/
package hack.oracle.apps.ame.dynamicapprovals.webui;

import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
// import the delivered Controller
import oracle.apps.ame.dynamicapprovals.webui.ApprovalsCO;
// import the HideShowHeader bean...
import oracle.apps.fnd.framework.webui.beans.layout.OAHideShowHeaderBean;

/**
* Controller for ...
*/
// make sure you extend the delivered CO...
public class hackApprovalsCO extends ApprovalsCO
{
public static final String RCS_ID="$Header$";
public static final boolean RCS_ID_RECORDED =
VersionInfo.recordClassVersion(RCS_ID, "%packagename%");

/**
* Layout and page setup logic for a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/

public void processRequest(OAPageContext pageContext, OAWebBean webBean)
{
// this line tells Oracle to run the default code, place your updates after it...
super.processRequest(pageContext, webBean);
pageContext.writeDiagnostics(this,"hackApprovalsCO - 10",3);
//
// instench-e-ate the HideShowHeader bean...
//
OAHideShowHeaderBean oaHideShowHeader = (OAHideShowHeaderBean)webBean.findIndexedChildRecursive("AdhocApproversShowHideRN");
//
// expand it...
//
oaHideShowHeader.setDefaultDisclosed(pageContext, Boolean.TRUE);
//
pageContext.writeDiagnostics(this,"hackApprovalsCO - 90",3);
}

/**
* Procedure to handle form submissions for form elements in
* a region.
* @param pageContext the current OA page context
* @param webBean the web bean corresponding to the region
*/
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
}
}


  1. Make
  2. Compile
  3. Save
  4. .zip
  5. FTP
  6. unzip
  7. personalize
  8. Apouncy batch

After you've compiled and saved your works, .zip up the directory and FTP it to $JAVA_TOP. Unzip it and then get into the application to point at your new Java file. Login to Manager Self Service and start a "Change Hours" transaction, hitting the review page and then clicking Personalize Page in the upper right-hand corner:


Click the Complete View radio button so you can find the item you need to edit:



Scroll down until you find this one:


Set the value of the Controller .class field to the following string. I happen to do this at the Responsibility level so that my hacking doesn't disrupt the work of others in the system:

hack.oracle.apps.ame.dynamicapprovals.webui.hackApprovalsCO


Click Apply and you'll be back on the Review page. In my case I had to pounce abatchy (bounce Apache) in order for this to take effect so wait 20 seconds if you have access to do this. You'll have to wait at least 4 hours if you need an overseas DBA to do it for you:

$ADMIN_SCRIPTS_HOME/adapcctl.sh stop
$ADMIN_SCRIPTS_HOME/adapcctl.sh start
$ADMIN_SCRIPTS_HOME/adoacorectl.sh stop
sleep 10
$ADMIN_SCRIPTS_HOME/adoacorectl.sh start

For added emphasis, enable Diagnostics before reviewing your handiwork by performing the following:




Now start a new transaction, striking the review page with great fervor. The HideShowHeader bean is expanded when the processRequest method is fired (when the page loads):



Scroll down deep into the diagnostics and find the debug messages you wrote to output:



And that is how to auto-expand a HideShowHeader bean in Oracle Applications using JDeveloper.