a が実行されるたびにコードを実行する方法はありますかnavigation rule
。基本的に私がやろうとしているJourneyTracker
のは、ジャーニーの現在の状態 (ユーザーがいる現在のページなど) を保持する Bean を持つことです。
1 に答える
5
これにはカスタムNavigationHandler
を使用できます。基本的に、その抽象クラスを次のように拡張するだけです。
public class MyNavigationHandler extends NavigationHandler {
private NavigationHandler wrapped;
public MyNavigationHandler(NavigationHandler wrapped) {
this.wrapped = wrapped;
}
@Override
public void handleNavigation(FacesContext context, String from, String outcome) {
// Do your job here. Just check if "from" and/or "outcome" matches the desired rule.
wrapped.handleNavigation(context, from, outcome); // Important! This will perform the actual navigation.
}
}
実行するには、次のように登録するだけですfaces-config.xml
。
<application>
<navigation-handler>com.example.MyNavigationHandler</navigation-handler>
</application>
于 2012-08-29T13:11:40.497 に答える