vineri, 13 martie 2015

[OmniFaces utilities (2.0)] Get/set the current view root


[OmniFaces utilities] The getViewRoot() method returns the current view root.
[OmniFaces utilities] The setViewRoot() method sets the current view root to the given view ID. The view ID must start with a leading slash. If an invalid view ID is given, then the response will simply result in a 404.

Methods:
See also: Faces#getContext()

Usage:

Get the view root example:
import org.omnifaces.util.Faces;
...
UIViewRoot viewRoot = Faces.getViewRoot();

This is a shortcut for:
FacesContext fc = FacesContext.getCurrentInstance();
UIViewRoot viewRoot = fc.getViewRoot();

Set the view root example:
import org.omnifaces.util.Faces;
...
Faces.setViewRoot("/index.xhtml");

Niciun comentariu:

Trimiteți un comentariu