1 15 package org.apache.tapestry.contrib.table.model.common; 16 17 import org.apache.tapestry.IRender; 18 import org.apache.tapestry.IRequestCycle; 19 import org.apache.tapestry.components.Block; 20 import org.apache.tapestry.components.BlockRenderer; 21 import org.apache.tapestry.contrib.table.model.ITableColumn; 22 import org.apache.tapestry.contrib.table.model.ITableModelSource; 23 import org.apache.tapestry.contrib.table.model.ITableRendererListener; 24 import org.apache.tapestry.contrib.table.model.ITableRendererSource; 25 import org.apache.tapestry.util.ComponentAddress; 26 27 32 public class BlockTableRendererSource implements ITableRendererSource 33 { 34 private static final long serialVersionUID = 1L; 35 36 private ComponentAddress m_objBlockAddress; 37 private ComponentAddress m_objListenerAddress; 38 39 public BlockTableRendererSource(Block objBlock) 40 { 41 this(new ComponentAddress(objBlock)); 42 } 43 44 public BlockTableRendererSource( 45 Block objBlock, 46 ITableRendererListener objListener) 47 { 48 this(new ComponentAddress(objBlock), new ComponentAddress(objListener)); 49 } 50 51 public BlockTableRendererSource(ComponentAddress objBlockAddress) 52 { 53 this(objBlockAddress, null); 54 } 55 56 public BlockTableRendererSource( 57 ComponentAddress objBlockAddress, 58 ComponentAddress objListenerAddress) 59 { 60 setBlockAddress(objBlockAddress); 61 setListenerAddress(objListenerAddress); 62 } 63 64 67 public IRender getRenderer( 68 IRequestCycle objCycle, 69 ITableModelSource objSource, 70 ITableColumn objColumn, 71 Object objRow) 72 { 73 ComponentAddress objListenerAddress = getListenerAddress(); 74 if (objListenerAddress != null) 75 { 76 ITableRendererListener objListener = 77 (ITableRendererListener) objListenerAddress.findComponent( 78 objCycle); 79 objListener.initializeRenderer( 80 objCycle, 81 objSource, 82 objColumn, 83 objRow); 84 } 85 86 Block objBlock = (Block) getBlockAddress().findComponent(objCycle); 87 return new BlockRenderer(objBlock); 88 } 89 90 94 public ComponentAddress getBlockAddress() 95 { 96 return m_objBlockAddress; 97 } 98 99 103 public void setBlockAddress(ComponentAddress blockAddress) 104 { 105 m_objBlockAddress = blockAddress; 106 } 107 108 112 public ComponentAddress getListenerAddress() 113 { 114 return m_objListenerAddress; 115 } 116 117 121 public void setListenerAddress(ComponentAddress listenerAddress) 122 { 123 m_objListenerAddress = listenerAddress; 124 } 125 126 } 127 | Popular Tags |