org.apache.tapestry.components
Interface IPrimaryKeyConverter

All Known Implementing Classes:
DefaultPrimaryKeyConverter

public interface IPrimaryKeyConverter

An interface for converting an objects to their primary keys and back. Typically used to determine how to store a given object as a hidden value when rendering a form.

This interface is used by the For component. When a primary key converter is available, it is used during the render, and as part of the rewind phase that processes the form submission.

During rendering, getPrimaryKey(Object) is invoked for each value. This method is invoked just before the For's body is rendered. The resulting primary key is written into the client as a hidden form field.

Likewise, during rewind, getValue(Object) is invoked for each key, to get back the same (or equivalent) object. Again, the method is invoked just before the For's body is rendered.

The DefaultPrimaryKeyConverter uses this relationship between a For component and its primary key converter to track what the current value being rendered or rewound is.

Since:
4.0
Author:
mb

Method Summary
 java.lang.Object getPrimaryKey(java.lang.Object value)
          Returns the primary key of the given value
 java.lang.Object getValue(java.lang.Object primaryKey)
          Returns the value corresponding the given primary key
 

Method Detail

getPrimaryKey

public java.lang.Object getPrimaryKey(java.lang.Object value)
Returns the primary key of the given value

Returns:
the primary key of the value

getValue

public java.lang.Object getValue(java.lang.Object primaryKey)
Returns the value corresponding the given primary key

Returns:
the generated value corresponding to the given primary key