Why is NavigationHandler.handleNavigation () not forwarding view ID?

Inside the phase listener class that runs during the "RESTORE_VIEW" phase, I have this code:

public void afterPhase(PhaseEvent event) {
  FacesContext fc = event.getFacesContext();
  NavigationHandler nh = fc.getApplication().getNavigationHandler();
  nh.handleNavigation(fc, null, "/a/specific/path/to/a/resource.jspx");
}

Navigating to the new URL does not work here. A request made will simply receive a response from the original JSPX to which the transition was made.

Code like this works fine:

public void afterPhase(PhaseEvent event) {
  FacesContext fc = event.getFacesContext();
  NavigationHandler nh = fc.getApplication().getNavigationHandler();
  nh.handleNavigation(fc, null, "OUTCOME_DEFINED_IN_FACES_CONFIG_XML");
}

Also the first snippet will work with the IceFaces Faces provider, but not with Sun JSF 1.2, which I have to use. Is there something I can do to fix the code so that certain URLs can be forwarded?

+3
source share
2 answers

, . :

public void afterPhase(PhaseEvent event) {
  FacesContext fc = event.getFacesContext();
  NavigationHandler nh = fc.getApplication().getNavigationHandler();
  fc.getViewRoot().setViewId("/a/specific/path/to/a/resource.jspx");
}
+1

Source: https://habr.com/ru/post/1739651/


All Articles