org.apache.tapestry
Interface ValueEncoder<V>

All Known Implementing Classes:
EnumValueEncoder, HibernateEntityValueEncoder, StringValueEncoder

public interface ValueEncoder<V>

Used to convert server side values to client-side strings. This is used when generating a EventContext as part of a URL, or when components (such as Select) generated other client-side strings.

Often a custom implementation is needed for entity type objects, where the toClient(Object) method extracts a primary key, and the toValue(String) re-acquires the corresponding entity object.

See Also:
SelectModel, ValueEncoderSource, PrimaryKeyEncoder

Method Summary
 String toClient(V value)
          Converts a value into a client-side representation.
 V toValue(String clientValue)
          Converts a client-side representation, provided by toClient(Object), back into a server-side value.
 

Method Detail

toClient

String toClient(V value)
Converts a value into a client-side representation. The value should be parseable by toValue(String). In some cases, what is returned is an identifier used to locate the true object, rather than a string representation of the value itself.

Parameters:
value - to be encoded
Returns:
a string representation of the value, or the value's identity

toValue

V toValue(String clientValue)
Converts a client-side representation, provided by toClient(Object), back into a server-side value.

Parameters:
clientValue - string representation of the value's identity
Returns:
the corresponding entity, or null if not found


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.