本实验基于《Task Flow使用指南之四:获取Task Flow返回值(1)》。
重要步骤说明:
1. 定制AM,增加一个方法,抛出异常,并发布到Client Interface
public void processData() {
throw new JboException("JboException! Data Processing Failed");
}
2. 修改employees-taskflow-btf
(1)增加一个Method Activity,绑定到processData
(2)修改employeeList页面,增加两个按钮:一个直接绑定到processData,一个导航到Method Activity。
<af:inputText label="Label 1" id="it1" value="#{pageFlowScope.deptId}"/>
<af:commandButton text="Go to ProcessData Method" id="cb2" action="toProcessData"/>
<af:commandButton actionListener="#{bindings.processData.execute}" text="Call processData"
disabled="#{!bindings.processData.enabled}" id="cb3" action="toReturn"/>
3. 运行
(1)点击Call ProcessData按钮
页面弹出一个窗口,提示异常发生:
同时,在Console日志中,输出如下信息:
<Utils> <buildFacesMessage> ADF: Adding the following JSF error message: JboException! Data Processing Failed
oracle.jbo.JboException: JboException! Data Processing Failed
at model.AppModuleImpl.processData(AppModuleImpl.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:655)
at oracle.adf.model.binding.DCDataControl.invokeMethod(DCDataControl.java:2162)
at oracle.adf.model.bc4j.DCJboDataControl.invokeMethod(DCJboDataControl.java:3088)
at oracle.adf.model.binding.DCInvokeMethod.callMethod(DCInvokeMethod.java:266)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1626)
at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2169)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:731)
at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:402)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:185)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
小结:使用按钮直接绑定抛出异常的方法,ADF会自动以弹出窗口的方式显示异常,用户友好性较好,开发人员不用做特别处理。
(2)点击Go to ProcessData Method按钮
页面上直接抛出500异常:
oracle.jbo.JboException: JBO-29114 ADFContext is not setup to process messages for this exception. Use the exception stack trace and error code to investigate the root cause of this exception. Root cause error code is JBO-.
at model.AppModuleImpl.processData(AppModuleImpl.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:655)
at oracle.adf.model.binding.DCDataControl.invokeMethod(DCDataControl.java:2162)
at oracle.adf.model.bc4j.DCJboDataControl.invokeMethod(DCJboDataControl.java:3088)
at oracle.adf.model.binding.DCInvokeMethod.callMethod(DCInvokeMethod.java:266)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1626)
at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2169)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:731)
at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:402)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:210)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(Unknown Source)
at com.sun.el.MethodExpressionImpl.invoke(Unknown Source)
同时,Console中输出如下信息:
<LifecycleImpl> <_handleException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase INVOKE_APPLICATION 5
oracle.jbo.JboException: JboException! Data Processing Failed
at model.AppModuleImpl.processData(AppModuleImpl.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.adf.model.binding.DCInvokeMethod.invokeMethod(DCInvokeMethod.java:655)
at oracle.adf.model.binding.DCDataControl.invokeMethod(DCDataControl.java:2162)
at oracle.adf.model.bc4j.DCJboDataControl.invokeMethod(DCJboDataControl.java:3088)
at oracle.adf.model.binding.DCInvokeMethod.callMethod(DCInvokeMethod.java:266)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1626)
at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2169)
at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:731)
at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:402)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:210)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(Unknown Source)
小结:使用Method Activity 绑定抛出异常的方法,ADF会在页面直接抛出异常,用户友好性较差,需要开发人员编写异常处理逻辑。
Project 下载:ADF_TaskFlow_PageToTaskFlow(ExceptionHandler1).7z
参考文献:
1. http://andrejusb.blogspot.jp/2011/03/exception-handler-for-method-calls_19.html
2. http://andrejusb.blogspot.com/2011/03/exception-handler-for-method-calls.html
没有评论:
发表评论