Task Flow使用指南之九中介绍了如何调用Remote TaskFlow, 但那是通过TaskFlow Call Activity调用的,如何通过程序调用一个Bounded TaskFlow呢?
首先我们必须知道TaskFlow的URL的格式,以Remote TaskFlow应用为例,其中的employee TaskFlow的URL如下:
http://127.0.0.1:7101/ADF_TaskFlow_RemoteProducer-ViewController-context-root/faces/adf.task-flow?adf.tfId=employee-btf&adf.tfDoc=/WEB-INF/employee-btf.xml&departmentId=60
其中参数adf.tfId是TaskFlow的ID,参数adf.tfDoc是TaskFlow的Document。
这两个参数对应TaskFlow Call Activity上的同名属性。
注意,我这里还带了一个参数departmentId,因为employee TaskFlow的输入参数就是departmentId。
你可以复制这个URL,直接在浏览器中访问,如果能看到departmentId=60的员工列表,就说明employee TaskFlow可以通过URL访问。
有了URL,我们就可以通过程序调用employee TaskFlow。
重要步骤说明:
1. 创建Remote TaskFlow Producer
这一步和《Task Flow使用指南之九》一样,这里不再赘述。
2. 在departments.jsf页面中,添加按钮:Invoke Employee TaskFlow
(1)页面代码如下:
<af:commandButton text="Invoke Employee TaskFlow" id="cb2" action="#{myBackingBean.invokeEmployeeTaskFlow}">
<af:setPropertyListener from="#{bindings.DepartmentId}" to="#{requestScope.departmentId}" type="action"/>
</af:commandButton>
(2)对应的Managed Bean的方法:invokeEmployeeTaskFlow
public String invokeEmployeeTaskFlow() {
FacesContext fctx = FacesContext.getCurrentInstance();
ExternalContext ectx = fctx.getExternalContext();
Map m = ectx.getRequestMap();
String tfId = "employee-btf";
String tfDoc = "/WEB-INF/employee-btf.xml";
Map
parameters.put("departmentId", m.get("departmentId"));
TaskFlowId taskflowId = new TaskFlowId(tfDoc, tfId);
//TaskFlowId taskflowId = TaskFlowId.parse("/WEB-INF/employee-btf.xml#employee-btf");
String taskflowUrl = ControllerContext.getInstance().getTaskFlowURL(false, taskflowId, parameters);
//String taskflowUrl = "http://127.0.0.1:7101/ADF_TaskFlow_RemoteProducer-ViewController-context-root/faces/adf.task-flow?adf.tfId=employee-btf&adf.tfDoc=/WEB-INF/employee-btf.xml&departmentId=60";
try {
ectx.redirect(taskflowUrl);
} catch (Exception e) {
e.printStackTrace();
}
return taskflowUrl;
}
Project 下载:ADF_TaskFlow_RemoteProducer.7z
参考文献:
1. http://oracleseeker.com/2009/10/28/adf_current_taskflow_id/
2. http://oracleseeker.com/2009/11/09/adf_backing_action_taskflow/
3. https://forums.oracle.com/forums/thread.jspa?threadID=1082973
4. https://blogs.oracle.com/jdevotnharvest/entry/how-to_navigate_in_bounded_task_flows
5. http://adfdeveloper.blogspot.jp/2011/07/adf-auto-redirect-while-still-passing.html
6. https://blogs.oracle.com/jdeveloperpm/entry/how-to_efficiently_redirect_to_an_adf_faces_view_using_adf_controller
7. http://udayarocks.wordpress.com/2011/07/22/how-to-invoke-a-method-from-managed-bean-when-jspx-page-loads-in-adf/
没有评论:
发表评论