需求:在页面上点某个按钮的时候,需要收集所有异常并抛出。
-------------------------------------------
方式1:参考 EBS OAF开发中的错误/异常处理(ErrorHandling) (转) 中消息集束的方式,在一个方法中定义消息集束并抛出。
方式2:在am中定义一个消息集束为全局变量,并在所有校验的地方将异常插入此变量,参考代码。
CO:
PoEvaluateAMImpl peAMImpl = (PoEvaluateAMImpl)am;
am.invokeMethod("initializeExceptionList");
checkRangeOverlap(pageContext, webBean); if(!peAMImpl.getExceptionList().isEmpty()){
peAMImpl.raiseBundledExceptions();
} private void checkRangeOverlap(OAPageContext pageContext,
OAWebBean webBean) throws OAException { OAApplicationModule am = pageContext.getApplicationModule(webBean);
PoEvaluateAMImpl peAMImpl = (PoEvaluateAMImpl)am;
OAException localOAException =
new OAException("PON", "PON_AUC_OVERLAP_RANGES");
if (!validateUniqueRanges(pageContext, webBean)) {
peAMImpl.getExceptionList().add(localOAException);
}
}
AM:
import com.sun.java.util.collections.ArrayList;
import com.sun.java.util.collections.Iterator;
import com.sun.java.util.collections.List; private transient List m_exceptionList = null; public void beforeRelease() {
super.beforeRelease();
this.m_exceptionList = null;
} private void setExceptionList(List paramList) {
this.m_exceptionList = paramList;
} public List getExceptionList() {
return this.m_exceptionList;
} public void initializeExceptionList() {
if (getExceptionList() == null) {
setExceptionList(new ArrayList());
} else {
getExceptionList().clear();
}
} public void raiseBundledExceptions() {
List localList = getExceptionList();
if ((localList != null) && (!localList.isEmpty())) {
OAException.raiseBundledOAException(localList);
}
}