1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.binding; |
16 |
| |
17 |
| import org.apache.hivemind.Location; |
18 |
| import org.apache.hivemind.util.Defense; |
19 |
| import org.apache.tapestry.BindingException; |
20 |
| import org.apache.tapestry.IAsset; |
21 |
| import org.apache.tapestry.IComponent; |
22 |
| import org.apache.tapestry.coerce.ValueConverter; |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| public class AssetBinding extends AbstractBinding |
31 |
| { |
32 |
| private final IComponent _component; |
33 |
| |
34 |
| private final String _assetName; |
35 |
| |
36 |
26
| public AssetBinding(String description, ValueConverter valueConverter, Location location,
|
37 |
| IComponent component, String assetName) |
38 |
| { |
39 |
26
| super(description, valueConverter, location);
|
40 |
| |
41 |
26
| Defense.notNull(component, "component");
|
42 |
26
| Defense.notNull(assetName, "assetName");
|
43 |
| |
44 |
26
| _component = component;
|
45 |
26
| _assetName = assetName;
|
46 |
| } |
47 |
| |
48 |
23
| public Object getObject()
|
49 |
| { |
50 |
23
| IAsset result = _component.getAsset(_assetName);
|
51 |
| |
52 |
23
| if (result == null)
|
53 |
1
| throw new BindingException(BindingMessages.missingAsset(_component, _assetName),
|
54 |
| _component, getLocation(), this, null); |
55 |
| |
56 |
22
| return result;
|
57 |
| } |
58 |
| |
59 |
1
| public Object getComponent()
|
60 |
| { |
61 |
1
| return _component;
|
62 |
| } |
63 |
| } |