|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
IPrimaryKeyConverter.java | - | - | - | - |
|
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
14 | ||
15 | package org.apache.tapestry.components; | |
16 | ||
17 | /** | |
18 | * An interface for converting an objects to their primary keys and back. Typically used to | |
19 | * determine how to store a given object as a hidden value when rendering a form. | |
20 | * <p> | |
21 | * This interface is used by the {@link org.apache.tapestry.components.ForBean For component}. When | |
22 | * a primary key converter is available, it is used during the render, and as part of the rewind | |
23 | * phase that processes the form submission. | |
24 | * <p> | |
25 | * During rendering, {@link #getPrimaryKey(Object)} is invoked for each value. This method is | |
26 | * invoked just before the For's body is rendered. The resulting primary key is written into the | |
27 | * client as a hidden form field. | |
28 | * <p> | |
29 | * Likewise, during rewind, {@link #getValue(Object)} is invoked for each key, to get back the same | |
30 | * (or equivalent) object. Again, the method is invoked just before the For's body is rendered. | |
31 | * <p> | |
32 | * The {@link org.apache.tapestry.util.DefaultPrimaryKeyConverter} uses this relationship between a | |
33 | * For component and its primary key converter to track what the current value being rendered or | |
34 | * rewound is. | |
35 | * | |
36 | * @author mb | |
37 | * @since 4.0 | |
38 | */ | |
39 | public interface IPrimaryKeyConverter | |
40 | { | |
41 | /** | |
42 | * Returns the primary key of the given value | |
43 | * | |
44 | * @param objValue | |
45 | * the value for which a primary key needs to be extracted | |
46 | * @return the primary key of the value | |
47 | */ | |
48 | Object getPrimaryKey(Object value); | |
49 | ||
50 | /** | |
51 | * Returns the value corresponding the given primary key | |
52 | * | |
53 | * @param objPrimaryKey | |
54 | * the primary key for which a value needs to be generated | |
55 | * @return the generated value corresponding to the given primary key | |
56 | */ | |
57 | Object getValue(Object primaryKey); | |
58 | ||
59 | } |
|