Exception in OAF

Introduction

Here we will see all about the Exception in OAF. As we know that OAF is a framework built on JAVA and J2EE Technology, hence it automatically import the entire Exception Handling mechanism as well. Yes that try{} catch{}, finally{} stuff. But in this article, we will discuss additional capabilities or features specific to OAF. In OAF, normally to show some messages to the end user of the OAF application, Exception is thrown with proper messages sometimes with dynamic or parameterized values (e.g Employee’s name) as well. OA Framework provides a class in order to achieve this:

oracle.apps.fnd.framework.OAException

Types of Exception

UsingA�OAException, single error and multiple errors, both can be shown. We will see. How?

Single:

throw new OAException(“Employee is created successfully”, OAException.INFORMATION);

Multiple:

ArrayList errorMsgList = new ArrayList();

errorMsgList.add(new OAException(“Employee is created successfully”));

errorMsgList.add(new OAException(“An email is sent to Employee with Employee Number”));

OAException.raiseBundledOAException(errorMsgList);

Message Types

Now different types of messages can be shown using OAException. The messages can be classified into:

  • CONFIRMATION
  • INFORMATION
  • WARNING
  • ERROR

Implementation

To continue with our project (all blogs need to be followed sequentially), until our last activity ( Upload File in OAF), when we click on the Create Employee button, we were not sure whether data was saved or not because user were not confirmed in any way. To confirm, we had to query the Database table and get confirmation. Now we will show some message to the user once they enter data, click on Create Employee button and the data is saved successfully in the database. Let’s see the standard way of doing in OAF:

  1. We will create a message in Oracle EBS in Messages. (Navigation: Application Developer > Applications > Messages)
  2. In the Message, we want the newly created Employee name to be printed, hence NAME is made parameterized (All should be in CAPITAL with prefix &).fnd_message_OAF
  3. Now once the data is saved successfully in the database, we will have to show this message to the user. For this few lines of code is written after commitData() call in processFormRequest() of the Controller. Here it is:
    String empName = (String)rootAM.invokeMethod(“getEmpName”); // Get the Employee Name from AM method
    MessageToken tokens[] = { new MessageToken(“NAME”,empName)};
    throw new OAException(“SQLAP”,”XXRD_RECORD_CREATE_MSG”,tokens,OAException.CONFIRMATION,null);So Employee name is derived from AM method “getEmpName”, then ‘NAME’ parameter is replaced by the value of empName and then OAException is instantiated and thrown to show to the Page.Let’s have a look at the constructor OAException() used here,OAException(String applicationShortName, String messageName, MessageToken[] tokens, Byte typeOfMessage, Exception[]A�details). Parameter names are self-explanatory.
  4. Code of getEmpName() in XXRDRootAMImpl:public String getEmpName(){
    XXRDEmpVOImpl empVO = getXXRDEmpVO1();
    return (empVO.getCurrentRow().getAttribute(“EmpName”)).toString();
    }
  5. Now the output looks like:exception_message_OAFThe message is of type CONFIRMATION.

So this is all about Exception in OAF. I believe this article might have helped you to know about how to show message through Exception in OAF. In our next blog, we will see how to implement Dialog Page in OAF.

Leave a Reply

Your email address will not be published. Required fields are marked *

Show my latest post here