My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...

.

.

.

.

.

.

.

.


[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians

Twitter

luni, 9 martie 2015

[OmniFaces utilities (2.0)] Get faces servlet mapping


[OmniFaces utilities] The getMapping() method determines and returns the faces servlet mapping used in the current request. If JSF is prefix mapped (e.g. /faces/*), then this returns the whole path, with a leading slash (e.g. /faces). If JSF is suffix mapped (e.g. *.xhtml), then this returns the whole extension (e.g. .xhtml).

[OmniFaces utilities] The isPrefixMapping() method returns whether the faces servlet mapping used in the current request is a prefix mapping.

Method:

For JSF, the faces servlet mapping is specified in web.xml file as below (several common cases):

·         without prefix mapping (with suffix mapping, *.xhtml)

<servlet-mapping>
 <servlet-name>Faces Servlet</servlet-name>
 <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

·         common prefix mapping (e.g. /faces/*).

<servlet-mapping>
 <servlet-name>Faces Servlet</servlet-name>
 <url-pattern>/faces/*</url-pattern>
</servlet-mapping>

·         un-common prefix mapping (e.g. /797b/*).

<servlet-mapping>
 <servlet-name>Faces Servlet</servlet-name>
 <url-pattern>/797b/*</url-pattern>

</servlet-mapping>

Usage:

import org.omnifaces.util.Faces;
...
String mapping = Faces.getMapping(); //e.g. prefixes: /faces, /797b
                                            suffixes: .xhtml
or,

import static org.omnifaces.util.Faces.getMapping;
...
String mapping = getMapping(); //e.g. prefixes: /faces, /797b
                                            suffixes: .xhtml

OmniFaces also comes with an OmniFaces utilities that returns true if the faces servlet mapping used in the current request is a prefix mapping. This OmniFaces utilities is named, isPrefixMapping():

Method:
Usage:

import org.omnifaces.util.Faces;
...
// e.g. for '/faces', '/797b' it returns true, while for '.xhtml' suffix, it will return false
boolean isprefix = Faces.isPrefixMapping();

or,

// e.g. for '/faces', '/797b' it returns true, while for '.xhtml' suffix, it will return false
import static org.omnifaces.util.Faces.isPrefixMapping;
...
boolean isprefix = Faces.isPrefixMapping();

Niciun comentariu :

Trimiteți un comentariu

JSF BOOKS COLLECTION

Postări populare

OmniFaces/JSF Fans

Visitors Starting 4 September 2015

Locations of Site Visitors