The best approach would be leveraging the ability to decorate the NavigationHandler.
This process is pretty straight forward.
1. Create a new NavigationHandler that accepts a NavigationHandler argument within
it's constructor.
public class CustomNavigationHandler extends NavigationHandler {
private NavigationHandler delegate;
public CustomNavigationHandler(NavigationHandler delegate) {
this.delegate = delegate;
}
public void handleNavigation(FacesContext ctx,
String fromAction,
String outcome) {
....
}
}
2. Implement handleNavigation(). My suggestion would be check the custom database rules
first of course and if you don't find any match, then delegate to the default navigation handler.
public void handleNavigation(FacesContext ctx,
String fromAction,
String outcome) {
// custom database-based navigation logic
// if match found handle the navigation tasks here
// no match found, delegate to the default NavigationHandler
delegate.handleNavigation(ctx, fromAction, outcome);
}
You can look at the source [1] for the default NavigationHandler implementation to
see what actions it takes when it matches a navigation based on the method parameters.
Hope this helps.
[1]
http://fisheye5.cenqua.com/browse/javaserverfaces-sources/jsf-ri/src/com/sun/faces/application/NavigationHandlerImpl.java?r=1.58
[Message sent by forum member 'rlubke' (rlubke)]
http://forums.java.net/jive/thread.jspa?messageID=292357