|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.bean; |
|
16 |
| |
|
17 |
| import org.apache.hivemind.util.Defense; |
|
18 |
| import org.apache.hivemind.util.PropertyUtils; |
|
19 |
| import org.apache.tapestry.IBeanProvider; |
|
20 |
| import org.apache.tapestry.IBinding; |
|
21 |
| import org.apache.tapestry.IComponent; |
|
22 |
| import org.apache.tapestry.binding.BindingConstants; |
|
23 |
| import org.apache.tapestry.binding.BindingSource; |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| public class BindingBeanInitializer extends AbstractBeanInitializer |
|
34 |
| { |
|
35 |
| private BindingSource _bindingSource; |
|
36 |
| |
|
37 |
| private String _bindingReference; |
|
38 |
| |
|
39 |
| |
|
40 |
18
| public BindingBeanInitializer(BindingSource source)
|
|
41 |
| { |
|
42 |
18
| Defense.notNull(source, "source");
|
|
43 |
| |
|
44 |
18
| _bindingSource = source;
|
|
45 |
| } |
|
46 |
| |
|
47 |
| |
|
48 |
| |
|
49 |
| |
|
50 |
18
| public void setBindingReference(String bindingReference)
|
|
51 |
| { |
|
52 |
18
| _bindingReference = bindingReference;
|
|
53 |
| } |
|
54 |
| |
|
55 |
| |
|
56 |
12
| public String getBindingReference()
|
|
57 |
| { |
|
58 |
12
| return _bindingReference;
|
|
59 |
| } |
|
60 |
| |
|
61 |
0
| public void setBeanProperty(IBeanProvider provider, Object bean)
|
|
62 |
| { |
|
63 |
0
| IComponent component = provider.getComponent();
|
|
64 |
| |
|
65 |
0
| String description = BeanMessages.propertyInitializerName(_propertyName);
|
|
66 |
| |
|
67 |
0
| IBinding binding = _bindingSource.createBinding(
|
|
68 |
| component, |
|
69 |
| description, |
|
70 |
| _bindingReference, |
|
71 |
| BindingConstants.OGNL_PREFIX, |
|
72 |
| getLocation()); |
|
73 |
| |
|
74 |
0
| Class propertyType = PropertyUtils.getPropertyType(bean, _propertyName);
|
|
75 |
| |
|
76 |
0
| Object bindingValue = binding.getObject(propertyType);
|
|
77 |
| |
|
78 |
0
| setBeanProperty(bean, bindingValue);
|
|
79 |
| } |
|
80 |
| } |