How to redirect or navigate to a different page with JSF

There are several ways of navigating from 1 page to another in JSF. There are 2 that I often use:

1.) Create a h:commandButton and tie it to an action that returns a string, which maps to a page: example return "home.xhtml".

2.) Using navigation handler:
ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) FacesContext.getCurrentInstance().getExternalContext().getApplication().getNavigationHandler();
navigationHandler.performNavigation("home");

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post
NERV Open Source
Building production Spring Boot systems?

Explore NERV — open-source Java libraries for audit trails, persistence, exception handling, and reliable event-driven architecture.