Wednesday, 31 July 2013

Purpose for Creating 'Zoom' in R12 OAF Page

In 11i the customer can do customization to open Custom Oracle Forms from Seeded Oracle Forms. But, this functionality is lost in R12 as the original Seeded Oracle Forms have been replaced by OAF pages. Now if customer wants to open Custom Oracle Forms from OAF page then  this can be done by creating a 'Zoom' button on the page. So on click of this button the Oracle Custom Form opens.

Zoom button in Oracle Forms 11i


Resultant Oracle Form opened on click of Zoom


Requirement
  • Create a button.
  • Validation:: If 'Purpose' is 'Bill to' then on button click form opens as per parameter 'SiteUseId' passed.
  • If 'Purpose' has any other value assigned then an exception is thrown.
Steps to Create a Zoom Button through Personalization:
  • Create a new column in the table.
  • Create a region to attach a custom controller.
  • Create a button inside the region and then write the code to call the Oracle Form inside the custom controller.
Calling Oracle Form from OAF Page
  • Set the Destination URI of the button with a value in the below format only if the form has to be opened without passing parameters.
form:responsibilityApplicationShortName:responsibilityKey:securityGroupKey:functionName
eg.   form:XX_AR:GEC_US_AR_SUPERUSER:STANDARD:XXAR_CUST_XREF_FUN
  • As per our requirement as run-time parameter has to be passed we have to call the controller.
  • Format for passing parameters and opening respective form is as below.
form:responsibilityApplicationShortName:responsibilityKey:securityGroupKey:functionName:param1=value1 param2=value2 param3=value3
  • Following is the code for the controller's processRequest and processFormRequest attached to 'Zoom' button.
 public void processRequest(OAPageContext pageContext, OAWebBean  webBean) 
{
 super.processRequest(pageContext, webBean);
 am = pageContext.getApplicationModule(webBean);

 OAButtonBean zoomBtn =                  OAButtonBean)webBean.findChildRecursive("XXBusPurColZoomBtn");

 if (zoomBtn != null) {
 Hashtable paramsWithBinds = new Hashtable(2);
 paramsWithBinds.put("SiteUseId",new        OADataBoundValueFireActionURL((OAWebBeanData)webBean, 
 "{$SiteUseId}")); // to get the current row reference for                          // attribute 'SiteUseId'

 paramsWithBinds.put("SiteUseCode",new                             OADataBoundValueFireActionURL((OAWebBeanData)webBean, 
 "{$SiteUseCode}")); // to get the current row reference for                          // attribute 'SiteUseCode'

 FireAction firePartialAction =
 OAWebBeanUtils.getFireActionForSubmit(zoomBtn,  "openCustRefDetForm", null, paramsWithBinds, true, true);
 // Programmatically attaching button action event for submit  button

 zoomBtn.setAttributeValue(PRIMARY_CLIENT_ACTION_ATTR,  firePartialAction);
        }
}

public void processFormRequest(OAPageContext pageContext,  OAWebBean webBean) 
{
 super.processFormRequest(pageContext, webBean);
 if("openCustRefDetForm".equals(pageContext.getParameter("event")  )) { 
 // Get the identifier of the PPR event source row

 if (pageContext.getParameter("SiteUseId") != null) 
 {
 if ("BILL_TO".equals(pageContext.getParameter("SiteUseCode"))) 
 { 
 // Form opens only when 'SiteUseCode' is 'BILL_TO' else  exception
                    
 String dest =                         "form:XX_AR:GEC_US_AR_SUPERUSER:STANDARD:XXAR_CUST_XREF_FUN:
 P_SITE_USE_ID=" + pageContext.getParameter("SiteUseId"); 
 // Calling a form and passing 'SiteUseId' as parameter

 pageContext.forwardImmediatelyToForm(dest);
 } 
 else 
 {
 throw new OAException("Only Work for BILL TO.Save the Work and  Click on Zoom If it is BILL TO",OAException.ERROR);  
 }
 }
 }
}

Zoom button implemented in R12


Resultant Oracle Form opened on click of Zoom


Benefits
  • With the click of Zoom we can easily open a form from OAF page.
  • We can pass parameters to the form as well.