Tuesday, September 13, 2011

OAF Custom Clear Button - Different Approaches


While working on Search Pages more often that not we cannot use the Result-Based or AutoCustomization Criteria, we go for Manual Search Pages. To implement "Clear" button is sometimes not mandatory, but nice to have feature there.

Before discussing various approaches, lets observe some features of standard Clear Button:
  • It doesn’t do form submit.
  • It doesn’t clear the results.
  • It doesn’t clear any other fields on the page apart from Search Criteria fields
  • Standard Clear Button is implemented with JavaScript.

Clear Button Scenarios and Approaches:-

Approach 1: Using Submit Button to clear the search criteria fields:

Following is the code snippet:

        if(pageContext.getParameter("ClearBtn") != null)
       {
              OAMessageTextInputBean searchCriteriaTxt1=
                 (OAMessageTextInputBean) webBean.findChildRecursive("SearchCriteriaTxt1") ;
              searchCriteriaTxt1.setText(pageContext, null);
              // searchCriteriaTxt1.setText(null); will through Developer Mode Exception
              // since it is processFormRequest.
         }

      Advantages:
  • You can achieve same functionality as standard Clear button by standard and supported behaviour.
       Disadvantages:
  • It needs a form submit.

Approach 2: Using Submit button and redirect to same page

Add following snippet in processFormRequest

         if (pageContext.getParameter("ClearBtn") != null)
         {
           pageContext.forwardImmediatelyToCurrentPage(null, false, null);
         }

      Advantages:
  • Usage is specific to a scenario.
       Disadvantages:
  • It needs a form submit.
  • AM is not retained.
  • Its much slower compared to other approaches.

Approach 3: Using Button (not submit button) with JavaScript to achieve exact functionality like the standard clear button:

Write following code in ProcessRequest and it'll do the trick !!

    String clearFunc = "function clearFunction()";
    clearFunc = clearFunc + "{";
    clearFunc = clearFunc + "document.getElementById('SearchItem1').value='';" ;
    clearFunc = clearFunc + "document.getElementById('SearchItem2').value='';" ;
    clearFunc = clearFunc + "}" ;
   
    pageContext.putJavaScriptFunction("clearFunction",clearFunc);
    OAButtonBean clearButton2 = (OAButtonBean) webBean.findChildRecursive("ClearButton2") ;
    String javaSClear = "javascript:clearFunction();";
    clearButton2.setOnClick(javaSClear);

     Advantages:
  • No form submit, so disadvantages from the first two approaches are overcome.
  • Exactly same behaviour as Standard Clear Button.

     Disadvantages:
  • Use of Java Script, which is not recommended by Oracle. But we can’t live with it in Consulting J.
Reset Button: An approach worth ignoring:

A "ResetButton" bean cannot be trusted to perform, Clear button’s job.
A Reset button only resets the values on Page to last submitted/saved values (which needn’t be blank).

For Example: You enter "Prince" in Employee Name Search Criteria on Employee Search Screen and click on Go.
Irrespective of whether any results came or not, these submitted values are saved.

Now if you change the value on Employee Name search criteria to "Arvind".
Clicking on Reset Button will reset the value to ‘Prince’ and not to the desired null value.

Friday, August 19, 2011

Oracle Fusion Was Released in May-2011

Oracle Fusion was released in May 2011. It was released without much publicity.
As of now it is under controlled availability.

Lets all wait for the big bang announcements and updates from Oracle on the NEXT-GEN ERP Suite.

Auto Repeating Layout

This can be used to repeat the content of a region based on the number of rows in VO (data source) attached to the region.

You can implement an auto-repeating layout in one or two levels:

One Level - you create a container web bean and attach a view object to it, which results in the replication of the container children based on the rows in the view object.

Two Levels - you create a master-detail relationship between two lists and create a view link to join them. The outer list replicates its container children based on the master view object and the inner list replicates its container children based on the detail view object.

ARL can be read only or updatable. In case of updatable (with form elements), ARL should be based only on a single view object. A layout with form elements allows you to update any row and submit your changes to update the underlying view object

Limitations:
  • You cannot implement a two-level auto-repeating layout with a list containing Form Elements.
  • OA Framework does not support view objects (for the Child View Usage) with composite primary keys. The view object should have a single-column primary key.
  • The items under an Auto Repeating Layout should not be made hidden/rendered on a Partial Page Refresh (PPR) event.If such a scenario exists, on a PPR event, the page should be re-rendered by calling pageContext.setForwardURL().
  • LOV's are not supported in Auto Repeating Layouts (ARLs).
  • ARL cannot implement in the following container regions directly or indirectly:
    • Table
    • Advanced Table
    • Hide/Show
    • Switcher
    • HGrid
    • SubTabLayout
Properties for Implementing this:
  • Child View Instance
  • Child View Attribute
  • View Link Instance (in case of two levels)
Due to these limitations its use is limited :).

Saturday, August 6, 2011

MDS in Oracle Applications, OAF



Like all popular frameworks available in market today, OAF encourages use of declarative objects. The declarative objects are stored in XML. Following XML files are created in OAF:

  1. UIX Pages and Regions.
  2. OAF Personalizations
  3. BC4J Substitutions (EO, VO Substitutions)
  4. BC4J Components (Eo.xml, VO.xml, AM.xml, AO.xml, VL.xml)
First 3 types of xml files are stored in separate database called MDS.
4th type is directly deployed in BC4J Container.

MDS stores all information about the UI and Personalizations. Substitution is equivalent to Site level Personalization.


Metadata is data about data, data describing data.
Service is unit of work as part of business process written to a specification.

MDS stands for Meta Data Services and it is the declarative metadata repository used with OA Framework applications. It replaced the older AK Repository.

MDS is normal Oracle Database which contains metadata related to all seeded OAF pages in Oracle Applications. By storing Pages and Regions information in database, framework allows page attributes and properties to be changed easily via Personalization.

Why is it called a Service?
MDS is delivery of XML on demand.
OA Framework Page, Personalizations, and BC4J substitutions are stored and managed in MDS.


The meta data for Personalizations and Custom Pages/Regions can either be in the form of XML files on the file system or stored in the MDS repository. All the seeded UI components are present in MDS directory on product top. By exporting meta data into XML files on the file system, you can easily move those files to another system or simply login to a different environment and import those XML files to a new database instance.

Please note: OAF UI and substitution declarative components are retrieved from the MDS. Even though the xml files may exist in the EBS file system, they are not the objects that gets executed.

JDR_UTILS is a PL/SQL package that allows you to evaluate the list of personalization documents that are in your MDS repository.

Following are 4 tables in the MDS Repository:


TableDetails
JDR_PATHSStores document paths, packages and there parent child relationship.
Primary Key: PATH_DOCID
JDR_COMPONENTSStores components on documents and OA Framework pages.
Primary Key: COMP_DOCID, COMP_SEQ
JDR_ATTRIBUTESStores attribute/properties of components on documents and OA Framework pages.
Primary Key: ATT_COMP_DOCID, ATT_COMP_SEQ, ATT_SEQ
JDR_ATTRIBUTES_TRANSStores translated attribute values of document components or OA framework pages.
Primary Key: ATL_COMP_DOCID, ATL_LANG, ATL_COMP_REF, ATL_NAME

Every Metadata definition of Page or Region is called document.



Following are few queries to understand the above tables:

Query1:
select distinct path_type 
from JDR_PATHS;
/
Result:
DOCUMENT (for pages and regions)
PACKAGE (for packages/directories path)

Query2:
select * 
from JDR_PATHS 
where path_name = 'HelloWorldPG' ;
/
-- Get familiar with the table structure, path_type will be 'DOCUMENT' for this record.

Query3:
select * 
from JDR_PATHS 
where path_docid = <path_owner_docid from query2>;
/
-- This record will point to the parent package/directory.

Query4:
select * 
from JDR_COMPONENTS 
where comp_docid = <path_doc_id>;
/
-- This will query components of the DOCUMENT. There are no records for a PACKAGE type.

Query5:
select * from JDR_ATTRIBUTES
where att_comp_docid = <path_doc_id>
and att_comp_seq = <sequence id of component whose properties you wish to check>;
/

Query6:
SELECT   jdr_mds_internal.getdocumentname (paths.path_docid) document_full_path,
               -- Fully Qualified personalized document name
               paths.path_name, -- Actual name of xml file
               --paths.path_docid,
               --paths.path_owner_docid, 

               -- Since All Personalized document reside in a package
               -- path_owner_docid will always point to a PACKAGE.
               --paths.path_type, 
               -- Path type is of two types PACKAGE and DOCUMENT
               -- PACKAGE indicates directory, DOCUMENT indicate xml file.
               -- This query will always retrieve DOCUMENT
               paths.path_seq,
               --attrs.att_comp_docid,
               --attrs.att_comp_seq, -- Always 0 because we are retrieving only page (top level)
               --attrs.att_name, -- Name of Attribute in personalization xml file
               -- Here we are querying for att_name = 'customizes'
               --attrs.att_seq, -- sequence at which attribute is occuring
               attrs.att_value -- value of the attribute here it'll be path of actual page

from        JDR_PATHS paths,
              JDR_ATTRIBUTES attrs
where      paths.path_docid = attrs.att_comp_docid
              -- This query will not fetch path_type= 'PACKAGE'
              -- As there are no jdr_attributes records for packages
              and attrs.att_comp_seq = 0 -- sequence value 0 indicates parent
              and attrs.att_name = 'customizes' -- indicates personalized documents,
              att_name = 'customizes' will always have att_comp_seq = 0
              and paths.last_update_date > to_date('01-JAN-11','DD-MON-RR')
                                                 -- Personalizations done in 2011
              and jdr_mds_internal.getdocumentname (paths.path_docid) like '%/function/%'
                                                 -- All Function Level Personalizations;
/

/*
because ATT_COMP_SEQ = 0; Result will ATT_NAME, ATT_VALUE pairs as mentioned in the first xml tag of the file.
Below is first xml tag from the HelloWorldPG from R12:
<page xmlns="http://xmlns.oracle.com/jrad" xmlns:ui="http://xmlns.oracle.com/uix/ui" xmlns:oa="http://xmlns.oracle.com/oa" xmlns:user="http://xmlns.oracle.com/jrad/user" version="9.0.3.9.1_1573" xml:lang="en-US" file-version="$Header: HelloWorldPG.xml 120.8 2006/05/25 13:15:58 atgops1 noship $">
*/

/*
For att_name = 'customizes' Att_seq is always 3, please check the 4rd attribute (count starts with 0 like arrays in our programming languages) from the below xml tag (This xml tag is from the personalization file of HelloWorldPG) :
<customization xmlns="http://xmlns.oracle.com/jrad" version="9.0.6.0.0_26" xml:lang="en-US" customizes="/oracle/apps/fnd/framework/toolbox/tutorial/webui/HelloWorldPG">
*/

Tuesday, July 19, 2011

OAF ContentContainer Region

ContentContainer region is used to display additional information on a page. Content container gives different look and feel to its content compared to other regions of OAF page.

Corresponding web bean: oracle.apps.fnd.framework.webui.beans.layout.OAContentContainerBean
UI property "Background Shade" (setBackground() method of bean) is used to set the background color.

Usage:

Though Content Container can be used anywhere in the OAF Page, it is typically placed at the side of the page in a dedicated column.

Below images are examples of usage of Content Container:



Implementation Approaches:

A) Within Page Content (Source: OAF Dev Guide)
This will not provide better look and feel. But in case if requirement is such, then go ahead and create a region with "ContentContainer" style. Create content container region like any other region for example Header etc.
  
B) At the side of your page (Source: OAF Dev Guide)
  1. Create a shared region for your content container.
  2. Programmatically add the shared region to the end area by writing following code in processRequest method:
OAContentContainerBean content = (OAContentContainerBean)createWebBean (pageContext,
    "<full path of the shared content container region>",
    null, // ignore item for regions
    true); // using OAExtension

// Get the page layout bean
OAPageLayoutBean pageLayoutBean =
    pageContext.getPageLayoutBean();

// Specify the content container as the end content.
pageLayoutBean.setEnd(content);

C) At the side of your page using TableLayout:
  1. This approach is not mentioned in Dev Guide and is very effective and very easy. This doesn't involve any Java programming.
  2. All you need to do is develop the layout of your page using the TableLayout region.
  3. Use the last column for ContentContainer.
  4. Using shared region is optional.

Wednesday, July 13, 2011

OAF Page without PageLayout Region

By default the highest level of region in OA Framework page is "pageLayout" region.
When we create a page, page gets created with PageLayout region.
I always felt PageLayout is mandatory region and has to be in all Pages.

But I was so wrong... You can create pages without PageLayout.

Sometime back, while working on a popup requirement (Custom Javascript popup) to display a table. I didn't liked the idea of popup having Corporate Logo, Global Links etc. Just tried to change the style of PageLayout region to other style and it worked.

Note: There are lot of restrictions on a page without PageLayout region, but it suited my requirements.

Table Suffix in Oracle Applications

_ALL are multi-org tables, on which org-striped views are based. Example po_headers_all and po_headers

_TL are translation tables, provide multiple language support. For each item in the table without _TL there can be many rows in the _TL table, but all with different values in the LANGUAGE column.
_VL are views for multi language tables which combines the row of the base table with the corresponding row of the _TL table where the LANGUAGE = USERENV('LANG').

_F these are date tracked tables which occur in HR and Payroll. For these there are two date columns EFFECTIVE_START_DATE and EFFECTIVE_END_DATE which together with the PK identifies a row uniquely. The date intervals cannot overlap. (This is also called Date Effectivity)

_B these are the BASE tables.
They are very important and the data is stored in the these table with all validations.
It is supposed that these table will always contain the perfect format data.
If anything happens to the BASE table data, then it is a data corruption issue.

_V are views.

_S are sequences.

_A are Audit Shadow Tables.

_AVn and _ACn are Audit Shadow Views (when data was changed, and with what values).

_DFV and _KFV: DFF/KFF table created on the base table. This is the best way to get the concatenated value of DFF/KFF. Also using this table the values can be queried based on the DFF/KFF name and not attributes column.

_X Current information table. There is no date tracking.