001 // Copyright 2007, 2008 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry.services;
016
017 import org.apache.tapestry.Block;
018
019 /**
020 * A source of {@link Block}s used to display the properties of a bean (used by the {@link
021 * org.apache.tapestry.corelib.components.Grid} component), or to edit the properties of a bean (used by the {@link
022 * org.apache.tapestry.corelib.components.BeanEditForm} component). Contributions to this service (a configuration of
023 * {@link BeanBlockContribution}s) define what properties may be editted.
024 * <p/>
025 * Blocks are accessed in terms of a <strong>data type</strong> a string that identifies the type of data to be editted,
026 * such as "string", "date", "boolean", etc.
027 * <p/>
028 * Tapestry contributes a number of default data types and corresponding edit and display blocks. The {@link
029 * org.apache.tapestry.services.BeanBlockOverrideSource} service allows these to be overridden.
030 *
031 * @see org.apache.tapestry.services.DataTypeAnalyzer
032 * @see org.apache.tapestry.services.TapestryModule#contributeBeanBlockSource(org.apache.tapestry.ioc.Configuration)
033 */
034 public interface BeanBlockSource
035 {
036 /**
037 * Returns a block which can be used to render an editor for the given data type, in the form of a field label and
038 * input field.
039 *
040 * @param datatype logical name for the type of data to be displayed
041 * @return the Block
042 * @throws RuntimeException if no appropriate block is available
043 */
044 Block getEditBlock(String datatype);
045
046 /**
047 * Returns a block which can be used to render output for the given data type.
048 *
049 * @param datatype logical name for the type of data to be displayed
050 * @return the Block
051 * @throws RuntimeException if no appropriate block is available
052 */
053 Block getDisplayBlock(String datatype);
054
055 /**
056 * Checks to see if there is a display block for the indicated data type.
057 *
058 * @param datatype to check for
059 * @return true if a block is available
060 */
061 boolean hasDisplayBlock(String datatype);
062 }