Monday, November 26, 2012

Bundled Exceptions in OAF


Some times we need throw a bundle of exceptions at a time
So for this type of requirement we can use OAException.raiseBundledOAException
Sample Code Snippet

ArrayList  errMsg = new ArrayList();                

if(row.getAttribute("Attribute1")==null)
       {
         errMsg.add(new OAException("Message 1",OAException.ERROR));
       }
       if(row.getAttribute("Attribute2")==null)
       {
         errMsg.add(new OAException("Message 2",OAException.ERROR));
       }
       if(!row.getAttribute("Attribute3").equals("SomeString"))
       {
       if(row.getAttribute("Attribute4")==null)
       {
         errMsg.add(new OAException("Message 3",OAException.ERROR));
       }
       if(row.getAttribute("Attribute5")==null)
       {
         errMsg.add(new OAException("Message 4",OAException.ERROR));
       }
//finally in the event for validation put this code
  if (errMsg.size()> 0)
     {
       OAException.raiseBundledOAException(errMsg);
     }

This will show a Error message like this on the Screen


No comments: