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

vineri, 8 mai 2015

[OmniFaces 2.0 utilities] Serialize/Unserialize and URL-safe


[OmniFaces utilities] The serializeURLSafe() method serialize the given string to the short possible unique URL-safe representation. The current implementation will decode the given string with UTF-8 and then compress it with ZLIB using "best compression" algorithm and then Base64-encode the resulting bytes without the = padding, whereafter the Base64 characters + and / are been replaced by respectively - and _ to make it URL-safe (so that no platform-sensitive URL-encoding needs to be done when used in URLs).
[OmniFaces utilities] The unserializeURLSafe() method unserialize the given serialized URL-safe string. This does the inverse of #serializeURLSafe(String).

Method Utils#serializeURLSafe() - Serialize the given string to the short possible unique URL-safe representation
See also: Utils#stream()

Method Utils#unserializeURLSafe() - Unserialize the given serialized URL-safe string
Usage:

// eNrTV_DPzct0S0xOLVawVfAKdlMoLcnMySypVMjJTCpKLKpU0AcAzDMLvQ
String serialized = Utils.serializeURLSafe("/ OmniFaces = JSF utility library /");
// / OmniFaces = JSF utility library /
String unserialized = Utils.unserializeURLSafe(serialized);

// eNrLKCkpsNLXz8_Ny0xLTE4t1k1LzCvWS8rJTy8uyC_RK8rXBwDehgy5
String serialized = Utils.serializeURLSafe("http://omnifaces-fans.blogspot.ro/");
// http://omnifaces-fans.blogspot.ro/
String unserialized = Utils.unserializeURLSafe(serialized);

// eNrLKCkpKLbS1y8t1s1NN9PLTczM0atMzMjP10vOz9XPS83Xz0kszUvOsNcrSsxLsU3JyCwzSixJNSmySMlSNjM0sjA1Njc0sgQAjaYX0w
String serialized = Utils.serializeURLSafe("https://us-mg6.mail.yahoo.com/neo/launch?.rand=dhiv2ate4r8dj#6128537129");
// https://us-mg6.mail.yahoo.com/neo/launch?.rand=dhiv2ate4r8dj#6128537129
String unserialized = Utils.unserializeURLSafe(serialized);

// eNozNFDQUjBV0FcwUdBWMFSwVTA01jMFACWyA4Q
String serialized = Utils.serializeURLSafe("10 * 5 / 4 + 1 = 13.5");
// 10 * 5 / 4 + 1 = 13.5
String unserialized = Utils.unserializeURLSafe(serialized);

You can see a real example in OmniFaces source code, CombinedResourceInfo.

Niciun comentariu :

Trimiteți un comentariu

JSF BOOKS COLLECTION

Postări populare

OmniFaces/JSF Fans

Visitors Starting 4 September 2015

Locations of Site Visitors