org.apache.tapestry5
Interface PrimaryKeyEncoder<K extends Serializable,V>

Type Parameters:
K - the type of the primary key, used to identify the value (which must be serializable)
V - the type of value identified by the key
All Known Implementing Classes:
DefaultPrimaryKeyEncoder

public interface PrimaryKeyEncoder<K extends Serializable,V>

Used by Loop, AjaxFormLoop and similar components to extract out an identifier, here termed a "primary key", that can be stored on the client and later used to recover the same, or equivalent, server side object.

The DefaultPrimaryKeyEncoder implementation is used in most circumstances.

See Also:
ValueEncoder

Method Summary
 void prepareForKeys(List<K> keys)
          Invoked as part of a form submission to alert the encoder that a series of keys may be converted back to values.
 K toKey(V value)
          Given a particular value, this method extracts and returns the primary key that identifies the value.
 V toValue(K key)
          For a particular primary key, previously obtained via toKey(Object), this method returns the same or equivalent object.
 

Method Detail

toKey

K toKey(V value)
Given a particular value, this method extracts and returns the primary key that identifies the value. The key will later be converted back into a value using toValue(Serializable).

Parameters:
value - whose primary key is needed
Returns:
the key for the value

prepareForKeys

void prepareForKeys(List<K> keys)
Invoked as part of a form submission to alert the encoder that a series of keys may be converted back to values. This is advisory only, and the keys passed to toValue(Serializable) may not include all keys in the list, or may include keys not in the list. In general, though, the keys passed in will match the actual keys to be converted, giving the encoder a chance to efficiently fetch the necessary value objects as a group.


toValue

V toValue(K key)
For a particular primary key, previously obtained via toKey(Object), this method returns the same or equivalent object.

Parameters:
key - used to identify the object
Returns:
the value object for the key


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