我有一个任务流,有两个像这样的图像:
我有一个按钮去那里,但我不需要点击按钮。我需要通过调用操作以编程方式重定向到另一个视图。
如何调用它,因为我使用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,我也会收到错误,例如编译器无法找到该组件。
你有另一种方法可以解决这个问题,或者如果我找错了找到组件你能解决吗?
答案 0 :(得分:2)
答案 1 :(得分:1)
对于这种情况,我使用此代码:
public static void navigateTo(String redirect) {
FacesContext facesContext = FacesContext.getCurrentInstance();
NavigationHandler nh = facesContext.getApplication().getNavigationHandler();
nh.handleNavigation(facesContext, null, redirect);
}
其中redirect参数是流案例规则的名称。