Exception Handling

Posted by raghu.yadav on Oracle Blogs See other posts from Oracle Blogs or by raghu.yadav
Published on Thu, 20 May 2010 07:41:33 -0800 Indexed on 2010/05/20 18:02 UTC
Read the original article Hit count: 670

Filed under:

Here is the few links on which andre had demonstrateddifferences-of-handling-jboexception-in
handling-exceptions-in-oracle-ui-shell
However in this post we can see how to display exception in popup being in the same page. I use similar usecase as andre however we'll not be using Exception Handling property from taskflow, instead we use popup and invoke the same programmatically.

This is a dynamic region example where user can select jobs or locations links to edit the records of corresponding tables being in the same page and click commit to save changes.
To generate exception we deliberately change commit to CommitAction in commit action binding code created in the bean (same as andre) and catch the exception and add brief description of exception into #{pageFlowScope.message}. Drop Popup component after Commit button and add dialog within in popup button, bind the popup component to backing bean and invoke the same in catch clause as shown below.

public String Commit() {
try{
BindingContainer bindings = getBindings();
OperationBinding operationBinding = bindings.getOperationBinding("CommitAction");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
return null;
}
}catch (NullPointerException e) {
setELValue("#{pageFlowScope.message}", "NullPointerException...");
e.printStackTrace();
String popupId =
this.getPopup().getClientId(FacesContext.getCurrentInstance());
PatternsPublicUtil.invokePopup(popupId);
}
return null;
}
}

private void setELValue(String el, String value) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ValueExpression valueExp =
expressionFactory.createValueExpression(elContext, el, Object.class);
valueExp.setValue(elContext, value);
}


excep1.PNG
excep2.PNG
excep3.PNG

.

© Oracle Blogs or respective owner