Pages

Recently Viewed

Tuesday, January 31, 2012

Raise Exception in OAF

Requirement – How to raise and handle exceptions in OAF pages.

Solution – There are 3 types of exceptions can be thrown on OAF pages (java).
a)      Warning  – This will display as warning and show custom message  
b)      Information  - This will display as information and show custom message
c)       Error – This will display your custom message as error and stop the flow.

In java (OAF) we use try catch block to handle exceptions.
Try Block – All logic should be kept in a try block to handle exceptions
Catch Block – Once control find any exception in try block, it goes to catch block. Catch block will be used to handle the raised exception.

Example -
try{ 
                                custom code{
……………;
…………….;
}   
  
throw new OAException("Sandeep");     // Raise Exception Manually     

                      }catch(Exception e)
                     {

                 throw new OAException("Exception " +e,  OAException.WARNING);         
                // For Warning Message
                 throw new OAException("Exception " +e,  OAException.INFORMATION);   
                // For Information Message   
                 throw new OAException("Exception " +e,  OAException.ERROR);             
               // For Error Message 
     }

If exception occurs in custom code, control will come to catch block and it will print the relative exception message on the screen.
If there is no exception in custom code, control will read last line. Which is to throw exception manually and send control to catch block.
Error message in this case will be as “Exception oracle.apps.fnd.framework.OAException: Sandeep”    

No comments:

Post a Comment