1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public class BlockTableRendererSource implements ITableRendererSource |
32 | |
{ |
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 | 0 | this(new ComponentAddress(objBlock)); |
42 | 0 | } |
43 | |
|
44 | |
public BlockTableRendererSource(Block objBlock, |
45 | |
ITableRendererListener objListener) |
46 | |
{ |
47 | 0 | this(new ComponentAddress(objBlock), new ComponentAddress(objListener)); |
48 | 0 | } |
49 | |
|
50 | |
public BlockTableRendererSource(ComponentAddress objBlockAddress) |
51 | |
{ |
52 | 0 | this(objBlockAddress, null); |
53 | 0 | } |
54 | |
|
55 | |
public BlockTableRendererSource(ComponentAddress objBlockAddress, |
56 | |
ComponentAddress objListenerAddress) |
57 | 0 | { |
58 | 0 | setBlockAddress(objBlockAddress); |
59 | 0 | setListenerAddress(objListenerAddress); |
60 | 0 | } |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public IRender getRenderer(IRequestCycle objCycle, |
67 | |
ITableModelSource objSource, ITableColumn objColumn, Object objRow) |
68 | |
{ |
69 | 0 | ComponentAddress objListenerAddress = getListenerAddress(); |
70 | 0 | if (objListenerAddress != null) |
71 | |
{ |
72 | 0 | ITableRendererListener objListener = (ITableRendererListener) objListenerAddress |
73 | |
.findComponent(objCycle); |
74 | 0 | objListener.initializeRenderer(objCycle, objSource, objColumn, |
75 | |
objRow); |
76 | |
} |
77 | |
|
78 | 0 | Block objBlock = (Block) getBlockAddress().findComponent(objCycle); |
79 | 0 | return new BlockRenderer(objBlock); |
80 | |
} |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
public ComponentAddress getBlockAddress() |
88 | |
{ |
89 | 0 | return m_objBlockAddress; |
90 | |
} |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public void setBlockAddress(ComponentAddress blockAddress) |
99 | |
{ |
100 | 0 | m_objBlockAddress = blockAddress; |
101 | 0 | } |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
public ComponentAddress getListenerAddress() |
109 | |
{ |
110 | 0 | return m_objListenerAddress; |
111 | |
} |
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
public void setListenerAddress(ComponentAddress listenerAddress) |
120 | |
{ |
121 | 0 | m_objListenerAddress = listenerAddress; |
122 | 0 | } |
123 | |
|
124 | |
} |