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, 1 mai 2015

[OmniFaces utilities (2.0)] Find/put a value associated with the specified key in the component's state


[OmniFaces utilities] This is a helper class for StateHelper that uses generic type-inference to make code that uses the StateHelper slightly less verbose.

Method get(Serializable key)- Attempts to find a value associated with the specified key in the component's state. Returns the value associated with the specified key.
Method get(Serializable key, Object defaultValue)-  Attempts to find a value associated with the specified key in the component's state. The value associated with the specified key, or the given default value if no value is found.
Method put(Serializable key, T value)- Puts a value in the component's state and returns the previous value. Returns The previous value, if any.

Usage:

The below example was extracted from the OmniFaces source code - component CommandScript:

import org.omnifaces.util.State;
...
private enum PropertyKeys {
 name, execute, render, onbegin, oncomplete;
}

private final State state = new State(getStateHelper());

public String getName() {
 return state.get(PropertyKeys.name);
}

public void setName(String name) {
 state.put(PropertyKeys.name, name);
}

public String getExecute() {
 return state.get(PropertyKeys.execute, "@this");
}

public void setExecute(String execute) {
 state.put(PropertyKeys.execute, execute);
}

public String getRender() {
 return state.get(PropertyKeys.render, "@none");
}

public void setRender(String render) {
 state.put(PropertyKeys.render, render);
}

public String getOnbegin() {
 return state.get(PropertyKeys.onbegin);
}

public void setOnbegin(String onbegin) {
 state.put(PropertyKeys.onbegin, onbegin);
}

public String getOncomplete() {
 return state.get(PropertyKeys.oncomplete);
}

public void setOncomplete(String oncomplete) {
 state.put(PropertyKeys.oncomplete, oncomplete);

}

Niciun comentariu :

Trimiteți un comentariu

JSF BOOKS COLLECTION

Postări populare

OmniFaces/JSF Fans

Follow by Email

Visitors Starting 4 September 2015

Locations of Site Visitors