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.corelib.components.Label;
18:
19: import static org.apache.tapestry.ioc.internal.util.Defense.notBlank;
20:
21: /**
22: * A contribution to the {@link BeanBlockSource} service, defining a page name and block id (within
23: * the page) that can edit or display a particular type of property.
24: */
25: public final class BeanBlockContribution {
26: private final String _dataType;
27:
28: private final String _pageName;
29:
30: private final String _blockId;
31:
32: private final boolean _edit;
33:
34: public BeanBlockContribution(String dataType, String pageName,
35: String blockId, boolean edit) {
36: notBlank(dataType, "datatype");
37: notBlank(pageName, "pageName");
38: notBlank(blockId, "blockId");
39:
40: _dataType = dataType;
41: _pageName = pageName;
42: _blockId = blockId;
43: _edit = edit;
44: }
45:
46: /**
47: * The type of data for which the indicated block will provide an editor or displayer for.
48: */
49: public String getDataType() {
50: return _dataType;
51: }
52:
53: /** The id of the block within the page. */
54: public String getBlockId() {
55: return _blockId;
56: }
57:
58: /**
59: * If true, then the block provides an editor for the property, consisting of a {@link Label}
60: * and some field component (or set of field components). If false, the block is used to display
61: * the value of the property, usually by applying some kind of formatting to the raw value.
62: */
63: public boolean isEdit() {
64: return _edit;
65: }
66:
67: /** The logical name of the page containing the block. */
68: public String getPageName() {
69: return _pageName;
70: }
71:
72: }
|