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.Binding;
18: import org.apache.tapestry.ComponentResources;
19: import org.apache.tapestry.ComponentResourcesCommon;
20: import org.apache.tapestry.Field;
21:
22: /**
23: * A service that can be injected into a component to provide common defaults for various
24: * parameters.
25: */
26: public interface ComponentDefaultProvider {
27: /**
28: * Computes the default label for the component (which will generally be a {@link Field}).
29: *
30: * @param resources
31: * @return the label, either extracted from the component's container's message catalog, or
32: * derived from the component's {@link ComponentResourcesCommon#getId()}.
33: */
34: String defaultLabel(ComponentResources resources);
35:
36: /**
37: * Checks to see if the container of the component (identified by its resources) contains a
38: * property matching the component's id. If so, a binding for that property is returned. This is
39: * usually the default for a {@link Field}'s value parameter (or equivalent).
40: *
41: * @param parameterName
42: * the name of the parameter
43: * @param resources
44: * the resources of the component for which a binding is needed
45: * @return the binding, or null if the container does not have a matching property
46: */
47: Binding defaultBinding(String parameterName,
48: ComponentResources resources);
49: }
|