您的位置:首页 > 编程语言

用代码实现页面Action跳转

2010-03-17 14:27 393 查看
概述

在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中添加如下方法:

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的代码如下:

public String cb1_action() {
navToOutCome("goPage2");
return null;
}


8、在page2.jspx中添加output text,设置其Value为“This is page2”

7、运行page1.jspx,查看结果









本文转自Oracle Seeker:http://oracleseeker.com/2009/11/09/adf_backing_action_taskflow/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: