|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.myfaces.orchestra.dynaForm.lib.ObjectSerializationConverter
public class ObjectSerializationConverter
Converter that can map a Serializable object into a plain java String.
This works like the standard java Serializable process, except that the resulting byte-array is then base64-encoded, ie is a String containing only ascii characters. The resulting value can safely be passed around as the "value" of a select-list, or a value embedded in a hidden field etc.
In particular, this allows the value of a SelectItem to be an object rather than a String, and the serialized form of a small object (such as the key class of a persistent entity) to be passed as a url query parameter.
Of course the object should not be too complicated, otherwise the string representation will be rather large!
| Field Summary | |
|---|---|
static NullObject |
SELECT_NULL_OBJECT
|
| Constructor Summary | |
|---|---|
ObjectSerializationConverter()
|
|
| Method Summary | |
|---|---|
Object |
getAsObject(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
String value)
Given a String that was previously created by the getAsString method on this class, "deserialize" the content of the string into a new Object instance. |
String |
getAsString(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value)
Return a serialized representation of the provided value, as a String type. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final NullObject SELECT_NULL_OBJECT
| Constructor Detail |
|---|
public ObjectSerializationConverter()
| Method Detail |
|---|
public Object getAsObject(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
String value)
throws javax.faces.convert.ConverterException
See method getAsString for more details.
getAsObject in interface javax.faces.convert.Converterjavax.faces.convert.ConverterException
public String getAsString(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
Object value)
throws javax.faces.convert.ConverterException
The provided value is serialized into a byte-array using normal java serialization, and the array is then base64-encoded. The result is a String that is safe to pass around in places that expect a String. The returned value can later be passed to the getAsToObject method of this class to recreate the value passed here.
The provided object must implement the Serializable interface.
getAsString in interface javax.faces.convert.Converterjavax.faces.convert.ConverterException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||