[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:
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