001// Copyright 2007, 2010 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 015package org.apache.tapestry5.services; 016 017import org.apache.tapestry5.corelib.components.Label; 018import org.apache.tapestry5.ioc.internal.util.InternalUtils; 019 020/** 021 * A contribution to the {@link BeanBlockSource} service, defining a page name and block id (within the page) that can 022 * edit or display a particular type of property. 023 */ 024public class BeanBlockContribution 025{ 026 private final String dataType; 027 028 private final String pageName; 029 030 private final String blockId; 031 032 private final boolean edit; 033 034 /** 035 * @deprecated Use {@link DisplayBlockContribution#DisplayBlockContribution(String, String, String)} or 036 * {@link EditBlockContribution#EditBlockContribution(String, String, String)} instead. To be 037 * removed after Tapestry 5.2. 038 */ 039 public BeanBlockContribution(String dataType, String pageName, String blockId, boolean edit) 040 { 041 assert InternalUtils.isNonBlank(dataType); 042 assert InternalUtils.isNonBlank(pageName); 043 assert InternalUtils.isNonBlank(blockId); 044 this.dataType = dataType; 045 this.pageName = pageName; 046 this.blockId = blockId; 047 this.edit = edit; 048 } 049 050 /** 051 * The type of data for which the indicated block will provide an editor or displayer for. 052 */ 053 public final String getDataType() 054 { 055 return dataType; 056 } 057 058 /** 059 * The id of the block within the page. 060 */ 061 public final String getBlockId() 062 { 063 return blockId; 064 } 065 066 /** 067 * If true, then the block provides an editor for the property, consisting of a {@link Label} and some field 068 * component (or set of field components). If false, the block is used to display the value of the property, usually 069 * by applying some kind of formatting to the raw value. 070 */ 071 public final boolean isEdit() 072 { 073 return edit; 074 } 075 076 /** 077 * The logical name of the page containing the block. 078 */ 079 public final String getPageName() 080 { 081 return pageName; 082 } 083 084}