sâmbătă, 6 februarie 2016

[OmniFaces utilities (2.3)] Get the base name of the current view without extension


[OmniFaces utilities] The getViewName() returns the base name of the current view, without extension, or null if there is no view. E.g. if the view ID is /path/to/some.xhtml, then this will return some.

Method:
See also: Faces#getViewId()
Usage:

import org.omnifaces.util.Faces;
...
String view = Faces.getViewName();

or

import org.omnifaces.util.FacesLocal;
...
String view = FacesLocal.getViewName(faces_context);

Output example:

// view ID: index.xhtml
// view name: index

// view ID: result.jsf
// view name: result

Niciun comentariu:

Trimiteți un comentariu