1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
package org.apache.tapestry.services.impl; |
16 |
|
|
17 |
|
import org.apache.hivemind.Location; |
18 |
|
import org.apache.tapestry.IComponent; |
19 |
|
import org.apache.tapestry.INamespace; |
20 |
|
import org.apache.tapestry.IRequestCycle; |
21 |
|
import org.apache.tapestry.Tapestry; |
22 |
|
import org.apache.tapestry.parse.ITemplateParserDelegate; |
23 |
|
import org.apache.tapestry.resolver.ComponentSpecificationResolver; |
24 |
|
import org.apache.tapestry.spec.IComponentSpecification; |
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
public class DefaultParserDelegate implements ITemplateParserDelegate |
33 |
|
{ |
34 |
|
private IComponent _component; |
35 |
|
|
36 |
|
private ComponentSpecificationResolver _resolver; |
37 |
|
|
38 |
|
private IRequestCycle _cycle; |
39 |
|
|
40 |
|
private String _componentAttributeName; |
41 |
|
|
42 |
|
public DefaultParserDelegate(IComponent component, String componentAttributeName, |
43 |
|
IRequestCycle cycle, ComponentSpecificationResolver resolver) |
44 |
0 |
{ |
45 |
0 |
_component = component; |
46 |
0 |
_componentAttributeName = componentAttributeName; |
47 |
0 |
_resolver = resolver; |
48 |
0 |
_cycle = cycle; |
49 |
0 |
} |
50 |
|
|
51 |
|
public boolean getKnownComponent(String componentId) |
52 |
|
{ |
53 |
0 |
return _component.getSpecification().getComponent(componentId) != null; |
54 |
|
} |
55 |
|
|
56 |
|
public boolean getAllowBody(String componentId, Location location) |
57 |
|
{ |
58 |
0 |
IComponent embedded = _component.getComponent(componentId); |
59 |
|
|
60 |
0 |
if (embedded == null) |
61 |
0 |
throw Tapestry.createNoSuchComponentException(_component, componentId, location); |
62 |
|
|
63 |
0 |
return embedded.getSpecification().getAllowBody(); |
64 |
|
} |
65 |
|
|
66 |
|
public boolean getAllowBody(String libraryId, String type, Location location) |
67 |
|
{ |
68 |
0 |
INamespace namespace = _component.getNamespace(); |
69 |
|
|
70 |
0 |
_resolver.resolve(_cycle, namespace, libraryId, type, location); |
71 |
|
|
72 |
0 |
IComponentSpecification spec = _resolver.getSpecification(); |
73 |
|
|
74 |
0 |
return spec.getAllowBody(); |
75 |
|
} |
76 |
|
|
77 |
|
public String getComponentAttributeName() |
78 |
|
{ |
79 |
0 |
return _componentAttributeName; |
80 |
|
} |
81 |
|
} |