Technical‎ > ‎OA Fwk‎ > ‎Misc‎ > ‎

Making an OA Framework page Readonly


All the folks who work on OA Framework(OAF) would know that there is no configuration option like we have in forms to make an OAF page read-only. Its a very common requirement.

I faced a similar situation where I had no option left but do research to find how we can make an OAF page read-only. After lot of research I found that in Release 12 Oracle Purchasing does render OAF pages in read-only mode. After decompiling hundreds of Oracle java classes I found the holy grail. A genius had written an awesome recursive function to set the read-only property on each bean in the bean hierarchy. Inspired by that code I wrote my own makeReadOnly function.

You can look at the class file oracle.apps.po.common.webui.ClientUtil.class.
The function which makes the page read-only is setViewOnlyRecursive.

All you need to do it call this function in the Process Request of your controller with following parameters (oapagecontext, oawebbean).

Below is the sample code I wrote to make the Account Overview page read-only and selectively hide columns on various tables so that user could not take any action that would lead to updation of the record. Today this is a std functionality as part of Receivables Inquiry responsibility.


/**
* Controller for Account Overview page
*/
public class XXAcctOviewPageCO extends AcctOviewPageCO
{
/**
* 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 oapagecontext, OAWebBean oawebbean)
{
super.processRequest(oapagecontext, oawebbean);
//Check if page invoked from Contact Center form.
String currUserRole = null;
String invokedFromForm = oapagecontext.getParameter("XXInvokedFromForm");

if("Y".equals(invokedFromForm))
{
currUserRole = (String) oapagecontext.getParameter("XXModeParam");

if(currUserRole == null)
{
oapagecontext.removeSessionValue("XXModeParam");
return;
}
else
{
oapagecontext.putSessionValue("XXModeParam", currUserRole);
}
}
else
{
currUserRole = (String) oapagecontext.getSessionValue("XXModeParam");
}
String custAcctSiteIdStr = oapagecontext.getParameter("XXCCAcctSiteId");


if("Role#1".equals(currUserRole) "Role#1".equals(currUserRole) "ReadOnly".equals(currUserRole))
{
//Render the page in View-Only Mode
ClientUtil.setViewOnlyRecursive(oapagecontext, oawebbean);

//Disable Save and Apply Button
OAWebBean pageButtonsBean = (OAWebBean) oapagecontext.getPageLayoutBean().getPageButtons();
OAWebBean pageButtonBean = (OAWebBean) pageButtonsBean.findIndexedChildRecursive("Save");
pageButtonBean.setRendered(false);
pageButtonBean = (OAWebBean) pageButtonsBean.findIndexedChildRecursive("Apply");
pageButtonBean.setRendered(false);

//Enable Search Filters on Account Sites Table
FormElementBean formElementBean = (FormElementBean)oawebbean.findIndexedChildRecursive("AcctSitesViewStatus");
formElementBean.setReadOnly(false);
formElementBean = (FormElementBean)oawebbean.findIndexedChildRecursive("SitePurposesFilter");
formElementBean.setReadOnly(false);
formElementBean = (FormElementBean)oawebbean.findIndexedChildRecursive("SiteOperatingUnitFilter");
formElementBean.setReadOnly(false);
formElementBean = (FormElementBean)oawebbean.findIndexedChildRecursive("ShowSitesFromOtherPartiesFilter");
formElementBean.setReadOnly(false);

//Hide Delete/Restore column on Account Sites Table
OAColumnBean col = (OAColumnBean) oawebbean.findIndexedChildRecursive("SiteDeleteCol");
col.setRendered(false);
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("SiteRestoreCol");
col.setRendered(false);

//Hide Remove column on Currencies Advanced Table
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("AdvTableC3");
col.setRendered(false);
//Hide Remove column on Receipt Methods Advanced Table
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("deleteColumn");
col.setRendered(false);

//Enable Search Filters on Account Contacts table
formElementBean = (FormElementBean)oawebbean.findIndexedChildRecursive("ActContStatus");
formElementBean.setReadOnly(false);
formElementBean = (FormElementBean)oawebbean.findIndexedChildRecursive("ShowContResp");
formElementBean.setReadOnly(false);

//Enable Search Filters on Account Relationships
formElementBean = (FormElementBean)oawebbean.findIndexedChildRecursive("RelStatusList");
formElementBean.setReadOnly(false);
//Hide the Remove and Restore columns on Account Relationships
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("RelRemoveCol");
col.setRendered(false);
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("RelRestoreCol");
col.setRendered(false);

//Adv Table: Account Contacts
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("ConRemoveCol");
col.setRendered(false);

//Adv Table:Currency Rates and Conditions
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("DeleteHdr");
col.setRendered(false);

col = (OAColumnBean) oawebbean.findIndexedChildRecursive("DuplicateHdr");
col.setRendered(false);

//Hide Update, Remove column on Credit Cards Adv Table
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("column7");
col.setRendered(false);
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("column8");
col.setRendered(false);
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("column9");
col.setRendered(false);

//Hide Inc/Dec Priority, Update, Debit Authorization columns on Bank Account Transfer:
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("column82");
col.setRendered(false);
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("column92");
col.setRendered(false);
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("column102");
col.setRendered(false);
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("column112");
col.setRendered(false);

//Adv Table: Attachments
OAImageBean img = (OAImageBean) oawebbean.findIndexedChildRecursive("Delete");
img.setRendered(false);
}
// Role#1 can create Sites
if("Role#1".equals(currUserRole))
{
//Enable the Table Actions on Account Sites Table.
OAAdvancedTableBean advTableBean = (OAAdvancedTableBean) oawebbean.findIndexedChildRecursive("AcctSitesTable");
UINode tableActions = advTableBean.getTableActions();
((OAWebBean)tableActions).setRendered(true);

//Enable the Delete & Restore actions on Account Sites Table.
OAColumnBean col = (OAColumnBean) oawebbean.findIndexedChildRecursive("SiteDeleteCol");
col.setRendered(true);
col = (OAColumnBean) oawebbean.findIndexedChildRecursive("SiteRestoreCol");
col.setRendered(true);
}
}

/**
* 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 oapagecontext, OAWebBean oawebbean)
{
super.processFormRequest(oapagecontext, oawebbean);
}
}

Free Hit Counters
Comments