|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry; |
|
16 |
| |
|
17 |
| import org.apache.commons.logging.Log; |
|
18 |
| import org.apache.commons.logging.LogFactory; |
|
19 |
| import org.apache.tapestry.engine.IPageLoader; |
|
20 |
| import org.apache.tapestry.spec.IComponentSpecification; |
|
21 |
| |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| public class BaseComponent extends AbstractComponent implements ITemplateComponent |
|
29 |
| { |
|
30 |
| private static final Log LOG = LogFactory.getLog(BaseComponent.class); |
|
31 |
| |
|
32 |
| private static final int OUTER_INIT_SIZE = 5; |
|
33 |
| |
|
34 |
| private IRender[] _outer; |
|
35 |
| |
|
36 |
| private int _outerCount = 0; |
|
37 |
| |
|
38 |
| |
|
39 |
| |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
2328
| public void addOuter(IRender element)
|
|
45 |
| { |
|
46 |
2328
| if (_outer == null)
|
|
47 |
| { |
|
48 |
591
| _outer = new IRender[OUTER_INIT_SIZE];
|
|
49 |
591
| _outer[0] = element;
|
|
50 |
| |
|
51 |
591
| _outerCount = 1;
|
|
52 |
591
| return;
|
|
53 |
| } |
|
54 |
| |
|
55 |
| |
|
56 |
| |
|
57 |
1737
| if (_outerCount == _outer.length)
|
|
58 |
| { |
|
59 |
147
| IRender[] newOuter;
|
|
60 |
| |
|
61 |
147
| newOuter = new IRender[_outer.length * 2];
|
|
62 |
| |
|
63 |
147
| System.arraycopy(_outer, 0, newOuter, 0, _outerCount);
|
|
64 |
| |
|
65 |
147
| _outer = newOuter;
|
|
66 |
| } |
|
67 |
| |
|
68 |
1737
| _outer[_outerCount++] = element;
|
|
69 |
| } |
|
70 |
| |
|
71 |
| |
|
72 |
| |
|
73 |
| |
|
74 |
| |
|
75 |
588
| private void readTemplate(IRequestCycle cycle, IPageLoader loader)
|
|
76 |
| { |
|
77 |
588
| loader.loadTemplateForComponent(cycle, this);
|
|
78 |
| } |
|
79 |
| |
|
80 |
| |
|
81 |
| |
|
82 |
| |
|
83 |
| |
|
84 |
| |
|
85 |
| |
|
86 |
654
| protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
|
|
87 |
| { |
|
88 |
654
| if (LOG.isDebugEnabled())
|
|
89 |
0
| LOG.debug("Begin render " + getExtendedId());
|
|
90 |
| |
|
91 |
654
| for (int i = 0; i < _outerCount; i++)
|
|
92 |
2502
| _outer[i].render(writer, cycle);
|
|
93 |
| |
|
94 |
615
| if (LOG.isDebugEnabled())
|
|
95 |
0
| LOG.debug("End render " + getExtendedId());
|
|
96 |
| } |
|
97 |
| |
|
98 |
| |
|
99 |
| |
|
100 |
| |
|
101 |
| |
|
102 |
| |
|
103 |
| |
|
104 |
| |
|
105 |
588
| public void finishLoad(IRequestCycle cycle, IPageLoader loader, IComponentSpecification specification)
|
|
106 |
| { |
|
107 |
588
| readTemplate(cycle, loader);
|
|
108 |
| |
|
109 |
567
| super.finishLoad(cycle, loader, specification);
|
|
110 |
| } |
|
111 |
| } |