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.tree.components.table; 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.ITableRendererSource; 022 import org.apache.tapestry.contrib.table.model.common.ComponentTableRendererSource; 023 import org.apache.tapestry.util.ComponentAddress; 024 025 /** 026 * @author ceco 027 */ 028 public class TreeTableValueRenderSource implements ITableRendererSource 029 { 030 031 private static final long serialVersionUID = 3237638859391458116L; 032 033 private ComponentTableRendererSource m_objComponentRenderer; 034 private ComponentAddress m_objComponentAddress = null; 035 036 /* used to synchronize access */ 037 private Object m_sync = new Object(); 038 039 public TreeTableValueRenderSource() 040 { 041 m_objComponentRenderer = null; 042 } 043 044 public TreeTableValueRenderSource(ComponentAddress objComponentAddress) 045 { 046 m_objComponentAddress = objComponentAddress; 047 } 048 049 /** 050 * @see org.apache.tapestry.contrib.table.model.ITableRendererSource#getRenderer(IRequestCycle, 051 * ITableModelSource, ITableColumn, Object) 052 */ 053 public IRender getRenderer(IRequestCycle objCycle, ITableModelSource objSource, ITableColumn objColumn, 054 Object objRow) 055 { 056 if (m_objComponentRenderer == null) 057 { 058 synchronized(m_sync) 059 { 060 ComponentAddress objAddress = m_objComponentAddress; 061 if (m_objComponentAddress == null) 062 objAddress = new ComponentAddress("contrib:TreeTableNodeViewPage", "treeTableNodeViewDelegator"); 063 m_objComponentRenderer = new ComponentTableRendererSource(objAddress); 064 } 065 } 066 067 return m_objComponentRenderer.getRenderer(objCycle, objSource, objColumn, objRow); 068 } 069 070 }