Sunday, 26 April 2015

Logging in Custom OAF Pages

Logging in Custom OAF Pages

We have often felt for years simple SOP (System.out.Println) is the best way of debugging in java/j2ee applications. I have the evil habit.. of putting lots of SOPs while writing code for OAF or ADF or simple j2ee applications. I generally create a method with sop in it eg:

private void putLogMsg(Object o)
{
System.out.println(o);
}


and call it with the code wherever required. The benefit is at the point of deployment of code, i just need to change this method from sop to writeDiagnostics().

private void putLogMsg(Object o)
{
pageContext.writeDiagnostics(this,o,OAFwkConstants.STATEMENT);
}


We should try not to put any SOPs in the deployed OAF/ADF code as it is can impact the performance.

Friday, 14 November 2014

Read Only Page in OAF

Introduction

OAF developers often come across requirements where they are required to render entire OAF page read-only and don’t want to edit any of the fields in the page. For example, a quote can be editable till it is submitted to Order Management (OM). But once the quote is submitted to OM, entire page should be rendered as Read-Only. But there is no built-in property for OAF pages and regions where we can set the read-only property true for the entire page.

There is utility class available in R12 instance for setting the entire page read-only.

Converting Page to read-only in R12 Instance:

The following are the steps for making Page Read-Only using utility class provided in R12.
1.    Modify the OA controller class attached to the page and import the seeded class oracle.apps.po.common.webui.ClientUtil

2.    Call the function ClientUtil.setViewOnlyRecursive(oapagecontext, oawebbean) when the required condition is satisfied for rendering the page read-only (i.e. we want to render the page read-only if session Value for PAGE_OPEN_MODE session variable is ‘Read only’), at the end of process request method.
The above steps would convert all types of items in the page as read-only (including the table details region)

Implementation

The read only conversion of the OAF page components can be implemented as below:

Custom Page

If the page is a custom page the method ClientUtil.setViewOnlyRecursive(oapagecontext, oawebbean) can be directly invoked from the processRequest method of the page’s controller.

Standard PageIf the page is a standard page, below steps are required:

·       Create a custom controller by extending with the standard page’s controller.
·       Upload the custom controller file to the server, provide the necessary permissions to the   file
·       Modify the page’s controller with reference to the custom controller through customizations.
·     Invoke the function ClientUtil.setViewOnlyRecursive(oapagecontext, oawebbean) from the processRequest method of the custom controller.

Wednesday, 12 November 2014

Export Data From OAF Table in Excel

Export Data From OAF Table in Excel

1. Below steps needs to be done on J developer.


  • Right Click on Table --> New --> Table Actions --> 

            
2. In the new Default Flow Region inside Table Actions, create a new item and select the item Style as export Button.

  • Table Actions Region




  • Item Properties


  • Save the Changes and Run the Page. The Output table Should look something like the below Screen.

3. Once user Clicks on Export button all the data in the table will be extracted a a text file. To Download Data as an Excel friendly format we need to set one Profile Option "FND_EXPORT_MIME_TYPE".

To set the profile from PLSQL use the below code:

DECLARE
   a   BOOLEAN;
BEGIN
   a := fnd_profile.SAVE ('FND_EXPORT_MIME_TYPE'
                        , 'application/excel'
                        , 'SITE'
                        , NULL
                        , NULL
                        , NULL
                         );

   IF a
   THEN
      DBMS_OUTPUT.put_line ('Success');
      COMMIT;
   ELSE
      DBMS_OUTPUT.put_line ('Error');
   END IF;
END;