001 // Copyright 2004, 2005 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.contrib.table.model.common;
016
017 import org.apache.tapestry.IRender;
018 import org.apache.tapestry.IRequestCycle;
019 import org.apache.tapestry.contrib.table.model.ITableColumn;
020 import org.apache.tapestry.contrib.table.model.ITableModelSource;
021 import org.apache.tapestry.contrib.table.model.ITableRendererListener;
022 import org.apache.tapestry.contrib.table.model.ITableRendererSource;
023 import org.apache.tapestry.util.ComponentAddress;
024
025 /**
026 * @author mindbridge
027 * @since 2.3
028 */
029 public class ComponentTableRendererSource implements ITableRendererSource
030 {
031
032 private static final long serialVersionUID = 1L;
033
034 private ComponentAddress m_objComponentAddress;
035
036 public ComponentTableRendererSource(ITableRendererListener objComponent)
037 {
038 this(new ComponentAddress(objComponent));
039 }
040
041 public ComponentTableRendererSource(ComponentAddress objComponentAddress)
042 {
043 setComponentAddress(objComponentAddress);
044 }
045
046 /**
047 * @see org.apache.tapestry.contrib.table.model.ITableRendererSource#getRenderer(IRequestCycle,
048 * ITableModelSource, ITableColumn, Object)
049 */
050 public IRender getRenderer(IRequestCycle objCycle,
051 ITableModelSource objSource, ITableColumn objColumn, Object objRow)
052 {
053 ITableRendererListener objComponent = (ITableRendererListener) getComponentAddress()
054 .findComponent(objCycle);
055
056 objComponent.initializeRenderer(objCycle, objSource, objColumn, objRow);
057
058 return objComponent;
059 }
060
061 /**
062 * Returns the listenerAddress.
063 *
064 * @return ComponentAddress
065 */
066 public ComponentAddress getComponentAddress()
067 {
068 return m_objComponentAddress;
069 }
070
071 /**
072 * Sets the listenerAddress.
073 *
074 * @param listenerAddress
075 * The listenerAddress to set
076 */
077 public void setComponentAddress(ComponentAddress listenerAddress)
078 {
079 m_objComponentAddress = listenerAddress;
080 }
081
082 }