001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005//     http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5.services;
014
015import org.apache.tapestry5.Block;
016import org.apache.tapestry5.ioc.annotations.UsesConfiguration;
017
018/**
019 * Used to override the default {@link org.apache.tapestry5.services.BeanBlockSource} for a particular data type.  The
020 * service accepts the same configuration of {@link org.apache.tapestry5.services.BeanBlockContribution}s as the main
021 * service.
022 */
023@UsesConfiguration(BeanBlockContribution.class)
024public interface BeanBlockOverrideSource
025{
026    /**
027     * Returns a block which can be used to render an editor for the given data type, in the form of a field label and
028     * input field.
029     *
030     * @param datatype logical name for the type of data to be displayed
031     * @return the Block
032     * @throws NullPointerException if no override is available
033     */
034    Block getEditBlock(String datatype);
035
036    /**
037     * Returns a block which can be used to render output for the given data type.
038     *
039     * @param datatype logical name for the type of data to be displayed
040     * @return the Block
041     * @throws NullPointerException if no override is available
042     */
043    Block getDisplayBlock(String datatype);
044
045    /**
046     * Checks to see if there is a display block for the indicated data type.
047     *
048     * @param datatype to check for
049     * @return true if an override display block is available
050     */
051    boolean hasDisplayBlock(String datatype);
052}