01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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.services;
16:
17: import org.apache.tapestry.Field;
18: import org.apache.tapestry.FieldValidator;
19: import org.apache.tapestry.Translator;
20: import org.apache.tapestry.annotations.Environmental;
21: import org.apache.tapestry.beaneditor.Validate;
22: import org.apache.tapestry.corelib.components.BeanEditForm;
23: import org.apache.tapestry.corelib.components.Label;
24: import org.apache.tapestry.ioc.Messages;
25:
26: /**
27: * Defines a context for editting a property of a bean via {@link BeanEditForm}. This value is made
28: * available to blocks via the {@link Environmental} annotation.
29: *
30: * @see BeanBlockSource
31: */
32: public interface PropertyEditContext {
33: /**
34: * Returns the current value of the property being editted (the context encapsulates the object
35: * containing the property).
36: */
37: Object getPropertyValue();
38:
39: /**
40: * Updates the value of the property being editted (the context encapsulates the object
41: * containing the property).
42: *
43: * @param value
44: * new value for the property
45: */
46: void setPropertyValue(Object value);
47:
48: /**
49: * Returns the user-presentable label, for use with the {@link Label} component, or to be
50: * integrated into any validation error messages.
51: */
52: String getLabel();
53:
54: /**
55: * Returns the translator appropriate for the field (this is based on the property type).
56: *
57: * @see TranslatorDefaultSource
58: */
59: Translator getTranslator();
60:
61: /**
62: * Returns the FieldValidator for the field.
63: *
64: * @see Validate
65: * @see FieldValidatorDefaultSource
66: */
67: FieldValidator getValidator(Field field);
68:
69: /**
70: * Returns a string that identifies the property, usually the property name. This is used as the
71: * basis for the client-side client id.
72: */
73: String getPropertyId();
74:
75: /**
76: * Returns the type of the property being editted.
77: */
78: Class getPropertyType();
79:
80: /**
81: * Returns the message catalog for the container of the {@link BeanEditForm}, which is the
82: * correct place to look for strings used for labels, etc.
83: */
84: Messages getContainerMessages();
85: }
|