2

我有一个任务流,并且有两个像这张图片一样的视图:

两个视图的示例

我有一个按钮可以去那里,但我不需要单击该按钮。我需要通过调用操作以编程方式重定向到另一个视图。

怎么称呼,因为我是用JSFF做页面的?

如果我使用这种方法:

       FacesContext fctx = FacesContext.getCurrentInstance();
   UIViewRoot root = fctx.getViewRoot();
   //client Id of button includes naming container like id of region. 
   RichCommandButton button = 
       (RichCommandButton) root.findComponent("cb1");
   ActionEvent actionEvent = new ActionEvent(button);
   actionEvent.queue();
   }

我收到一个错误,例如找不到组件。如果我使用页面模板 ID,我也会收到错误,例如编译器找不到组件。

你有另一种方法来解决这个问题,或者如果我找到错误的组件,你能解决它吗?

4

2 回答 2

2

您已使用“URL 视图”并将其重定向到您的路径:在此处输入图像描述

于 2016-07-11T11:14:58.117 回答
1

对于这种情况,我使用以下代码:

public static void navigateTo(String redirect) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    NavigationHandler nh = facesContext.getApplication().getNavigationHandler();
    nh.handleNavigation(facesContext, null, redirect);
}

其中重定向参数是流案例规则的名称。

于 2016-05-11T07:21:41.287 回答