1. 程式人生 > >在am中定義消息集束,並在CO中驗證之後拋出異常。

在am中定義消息集束,並在CO中驗證之後拋出異常。

void 按鈕 span lua throws ansi log oaf ext.get

需求:在頁面上點某個按鈕的時候,需要收集所有異常並拋出。

-------------------------------------------
方式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); } }

在am中定義消息集束,並在CO中驗證之後拋出異常。