2

1 つのタスクフローがあり、次の画像のような 2 つのビューがあります。

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

1

そのような場合、私はこのコードを使用します:

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

ここで、redirect param はフロー ケース ルールの名前です。

于 2016-05-11T07:21:41.287 に答える