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.ApplicationRuntimeException; |
18 |
| import org.apache.tapestry.IBeanProvider; |
19 |
| import org.apache.tapestry.IComponent; |
20 |
| import org.apache.tapestry.services.ExpressionEvaluator; |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| public class ExpressionBeanInitializer extends AbstractBeanInitializer |
31 |
| { |
32 |
| protected String _expression; |
33 |
| |
34 |
| private final ExpressionEvaluator _evaluator; |
35 |
| |
36 |
0
| public ExpressionBeanInitializer(ExpressionEvaluator evaluator)
|
37 |
| { |
38 |
0
| _evaluator = evaluator;
|
39 |
| } |
40 |
| |
41 |
0
| public void setBeanProperty(IBeanProvider provider, Object bean)
|
42 |
| { |
43 |
0
| IComponent component = provider.getComponent();
|
44 |
| |
45 |
0
| try
|
46 |
| { |
47 |
0
| Object value = _evaluator.read(component, _expression);
|
48 |
| |
49 |
0
| setBeanProperty(bean, value);
|
50 |
| } |
51 |
| catch (Exception ex) |
52 |
| { |
53 |
0
| throw new ApplicationRuntimeException(ex.getMessage(), getLocation(), ex);
|
54 |
| } |
55 |
| } |
56 |
| |
57 |
| |
58 |
| |
59 |
0
| public String getExpression()
|
60 |
| { |
61 |
0
| return _expression;
|
62 |
| } |
63 |
| |
64 |
| |
65 |
| |
66 |
0
| public void setExpression(String expression)
|
67 |
| { |
68 |
0
| _expression = expression;
|
69 |
| } |
70 |
| |
71 |
| } |