Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
IPropertySelectionModel |
|
| 1.0;1 |
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.form; | |
16 | ||
17 | /** | |
18 | * Used by a {@link PropertySelection} to provide labels for options. | |
19 | * <p> | |
20 | * The component requires three different representations of each option: | |
21 | * <ul> | |
22 | * <li>The option value, the server-side Java object that will eventually be assigned to a property | |
23 | * <li>The label, a string which is incorprated into the HTML to identify the option to the user | |
24 | * <li>The value, a client-side string which is used to represent the option as the value of the | |
25 | * <option> or <input type=radio> generated by the {@link PropertySelection}. | |
26 | * </ul> | |
27 | * <p> | |
28 | * The option is usually a string, a primitive value, or some kind of business object. The label is | |
29 | * often a property of the option object (for example, for a list of customers, it could be the | |
30 | * customer name). | |
31 | * <p> | |
32 | * It should be easy to convert between the value and the option. It may simply be an index into an | |
33 | * array. For business objects, it is often the primary key of the object, expressed as a String. | |
34 | * | |
35 | * @author Howard Lewis Ship | |
36 | */ | |
37 | ||
38 | public interface IPropertySelectionModel | |
39 | { | |
40 | /** | |
41 | * Returns the number of possible options. | |
42 | */ | |
43 | ||
44 | int getOptionCount(); | |
45 | ||
46 | /** | |
47 | * Returns one possible option that will be assigned to the server-side property. | |
48 | */ | |
49 | ||
50 | Object getOption(int index); | |
51 | ||
52 | /** | |
53 | * Returns the label for an option. It is the responsibility of the adaptor to make this value | |
54 | * localized. | |
55 | */ | |
56 | ||
57 | String getLabel(int index); | |
58 | ||
59 | /** | |
60 | * Returns a String used to represent the option in the HTML (as the value of an <option> | |
61 | * or <input type=radio>. This value is not visible to the user, and is often an index | |
62 | * into an array. | |
63 | */ | |
64 | ||
65 | String getValue(int index); | |
66 | ||
67 | /** | |
68 | * Used to help rendering of options that should be marked with the html <code>disabled</code> | |
69 | * attribute. | |
70 | * | |
71 | * @param index The option to check. | |
72 | * @return True if the option shouldn't be selectable, false otherwise. | |
73 | */ | |
74 | boolean isDisabled(int index); | |
75 | ||
76 | /** | |
77 | * Returns the option corresponding to a value. This is used when interpreting submitted form | |
78 | * parameters. | |
79 | */ | |
80 | ||
81 | Object translateValue(String value); | |
82 | } |