用代码实现页面Action跳转
十一月 9, 2009 in Oracle 融合中间件
概述
在ADF 11g中,Task-Flow作为应用开发的最小颗粒度,在实际的应用中发挥着重要作用。对于不同页面之间的跳转关系,可以在Task-Flow中通过Action进行指定和控制,除使用Common Component直接指定Action进行跳转外,还可以在Backing Bean中用代码实现Task-Flow中定义的页面跳转。本文将介绍如何在Backing Bean中用代码实现页面Action的跳转。
实现
1、创建ADF应用
2、在ViewController项目中创建两个新页面,分别为page1.jspx和page2.jspx,为方便处理,在生成页面的同时分别为两个页面创建backing bean
3、将page1和page2分别拖动到adfc-config.xml中,设置control flow rule由page1到page2,设置后的adfc-config.xml应如图:
4、在page1.jspx中添加commond button,双击该按钮,在backing bean中创建该按钮对应的action方法cb1_action
5、page1对应的backing bean中添加如下方法:
1 2 3 4 5 6 7 8 9 10 11 12 | public void navToOutCome(String outCome) { FacesContext facesContext = FacesContext.getCurrentInstance(); Application application = facesContext.getApplication(); NavigationHandler navigationHandler = application.getNavigationHandler(); ControllerContext controllerContext = ControllerContext.getInstance(); String viewId = controllerContext.getCurrentViewPort().getViewId(); if (viewId != null) { navigationHandler.handleNavigation(facesContext, viewId, outCome); } } |
6、修改cb1_action的代码如下:
1 2 3 4 | public String cb1_action() { navToOutCome("goPage2"); return null; } |
8、在page2.jspx中添加output text,设置其Value为“This is page2”
7、运行page1.jspx,查看结果
相关代码请查看:howtocodeaction.rar
相关文章:
0 responses to 用代码实现页面Action跳转