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

marți, 19 aprilie 2016

[OmniFaces utilities 2.4] URI-encode the given string using UTF-8


[OmniFaces utilities] The encodeURI() method encodes the given string using UTF-8. URIs (paths and filenames) have different encoding rules as compared to URLs. URLEncoder is actually only for www (HTML) form based query string parameter values. URI encoding has a lot in common with URL encoding, but the space has to be %20 and some chars doesn't necessarily need to be encoded.

Method
Usage

import org.omnifaces.util.Utils;
...
// http%3A%2F%2Fwww.names.org%3Fname%3DAnghel%20Leonard
String encode_uri = Utils.encodeURI("http://www.names.org?name=Anghel Leonard");

// check #encodeURL() also
// http%3A%2F%2Fwww.names.org%3Fname%3DAnghel+Leonard
String encode_url = Utils.encodeURL("http://www.names.org?name=Anghel Leonard");

Notice how the empty space was encoded by #encodeURI() as %20, while #encodeURL() as +.

Niciun comentariu :

Trimiteți un comentariu

JSF BOOKS COLLECTION

Postări populare

Follow by Email

Visitors Starting 4 September 2015

Locations of Site Visitors