Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For straightforward page changes, return a view outcome from a JSF action and let implicit navigation resolve it. Add a redirect when the browser should load a new URL, use explicit navigation cases when transitions need central rules, and use Faces Flows for multi-step tasks with defined entry and exit points.

Choose the navigation mechanism that fits the transition

JSF navigation determines which view follows an action, such as clicking a button or link. The simplest approach is often the best; add configuration only when the transition needs it.

Approach Best fit Configuration location Browser behavior
Implicit navigation A simple transition to a view Action method or component outcome Normally uses the JSF view transition; add a redirect suffix when a new browser request is wanted
Explicit navigation case A transition with a declared source, outcome, condition, destination, redirect, or parameters faces-config.xml Forward by default; can be configured to redirect
Bookmarkable URL generation A link or button whose URL should include view parameters Facelets component and view parameters Generates a URL for the destination view
Faces Flow A multi-step task with entry, internal views, and an exit path Flow configuration and views Uses flow navigation rules
Custom NavigationHandler Application-wide dynamic navigation policy not expressed cleanly by standard rules Application infrastructure Defined by the custom handler

Use implicit navigation for ordinary view changes

When no explicit navigation case matches, JSF can interpret an action outcome as a view name and derive the destination. This keeps simple transitions close to the action that triggers them. Use a consistent outcome naming convention so action methods communicate application intent rather than scattering URL construction throughout the code.

For example, a save action can redirect to a detail view and include the saved record’s identifier:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
public String save() {
    service.save(entity);
    return "detail?faces-redirect=true&id=" + entity.getId();
}

The faces-redirect=true suffix requests an HTTP redirect. The query parameter is incorporated into the navigation URL under JSF’s parameter rules. Encode and validate identifiers, and do not put secrets or mutable authorization decisions in a query string.

Move transitions into faces-config.xml when rules need to be explicit

An explicit navigation case is useful when a transition depends on the source view and outcome, must be reviewed centrally, or needs a declared redirect policy or parameters. For example:

<navigation-rule>
  <from-view-id>/edit.xhtml</from-view-id>
  <navigation-case>
    <from-outcome>saved</from-outcome>
    <to-view-id>/detail.xhtml</to-view-id>
    <redirect>
      <include-view-params>true</include-view-params>
    </redirect>
  </navigation-case>
</navigation-rule>

The source view can be an exact match, a wildcard prefix ending in *, or the global wildcard *. If multiple source patterns match, JSF selects the longest matching pattern. Keep broad wildcard rules deliberate: they can apply beyond the view where a reader first encounters them.

A navigation case can also use an EL if condition. In the JSF 2.3 schema, that condition is evaluated when matching the case; without a from-outcome, it can determine whether a null-outcome case matches. Keep these expressions short and side-effect free. Put authorization and business decisions in application services, then navigate using a clear outcome.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Redirect when the destination should become the browser’s URL

A redirect tells the browser to make a new request for the destination instead of relying on the usual ViewHandler transition. This is useful after a POST-style state change: refreshing the destination then requests that URL rather than resubmitting the preceding form. It also gives the destination a URL that can be copied or bookmarked, provided the view and its required parameters support that use.

In an explicit navigation case, a <redirect> element can include <redirect-param> children and the include-view-params attribute. A redirect changes request behavior; it is not a performance guarantee. Choose it for the URL and refresh semantics the application needs, not an assumed speed improvement.

Pass redirect parameters without accidental collisions

JSF redirect query parameters may come from the implicit-navigation outcome, view parameters, and nested f:param values. The JSF 2.3 specification and Jakarta Faces 3.0 specify this precedence, with later sources replacing earlier values of the same name:

  1. Parameters in the implicit-navigation outcome are applied first.
  2. View parameters are applied next and replace same-named outcome parameters.
  3. Nested f:param values are applied last and replace same-named values from either earlier source.

For example, if the outcome supplies id=1, a view parameter supplies id=2, and a nested f:param supplies id=3, the resulting value is id=3. Avoid reusing parameter names unless overriding is intentional; otherwise, a later source can silently change the destination URL’s value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Generate bookmarkable links for views with parameters

For links and buttons that need a destination URL, JSF’s Facelets mechanisms collect applicable nested UIParameter values, navigation-case parameters, flow parameters, and view parameters before asking the ViewHandler to generate a bookmarkable URL. This is preferable to hand-building a link when the view has declared parameters or the destination depends on navigation metadata.

Bookmarkability does not make a URL private or trustworthy. Treat all query-string values as user-controlled input, validate them on the server, and keep credentials and authorization state out of the URL.

Use Faces Flows for multi-step work

Faces Flows, introduced in JSF 2.2, give a multi-view task a defined structure: an entry point, internal view nodes, and an explicit return or exit path. Use a flow when those boundaries help organize a task, rather than modeling a sequence of related screens as unrelated navigation outcomes. Flow-node resolution and navigation-case processing are part of the JSF navigation algorithm.

Reserve a custom NavigationHandler for genuinely dynamic policy

A custom NavigationHandler can implement application-specific behavior such as dynamic redirect prefixes or centralized processing of parameters. Apache MyFaces documents examples that interpret a redirect: outcome and add an evaluated object identifier to the redirect URL. Such a handler is infrastructure: centralize and document it, and avoid making it the default convention for transitions that implicit navigation already handles clearly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the JSF or Jakarta Faces version before copying configuration

JSF 2.3 is the final Java EE-era JSF specification. Jakarta Faces 3.0 carries the navigation model forward under the Jakarta namespace. Check the namespace and implementation version used by your application before copying configuration or imports; Java EE-era and Jakarta-era applications do not necessarily use the same package names or configuration namespace.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.