|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.test; |
|
16 |
| |
|
17 |
| import org.apache.hivemind.Location; |
|
18 |
| import org.apache.tapestry.enhance.EnhanceUtils; |
|
19 |
| import org.apache.tapestry.enhance.EnhancementOperation; |
|
20 |
| import org.apache.tapestry.enhance.EnhancementWorker; |
|
21 |
| import org.apache.tapestry.spec.IComponentSpecification; |
|
22 |
| |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| public class CreatePropertyWorker implements EnhancementWorker |
|
31 |
| { |
|
32 |
| private final String _propertyName; |
|
33 |
| |
|
34 |
| private final Location _location; |
|
35 |
| |
|
36 |
972
| public CreatePropertyWorker(String propertyName, Location location)
|
|
37 |
| { |
|
38 |
972
| _propertyName = propertyName;
|
|
39 |
972
| _location = location;
|
|
40 |
| } |
|
41 |
| |
|
42 |
1020
| public void performEnhancement(EnhancementOperation op, IComponentSpecification spec)
|
|
43 |
| { |
|
44 |
1020
| Class propertyType = EnhanceUtils.extractPropertyType(op, _propertyName, null);
|
|
45 |
| |
|
46 |
1020
| op.claimProperty(_propertyName);
|
|
47 |
| |
|
48 |
1020
| String field = "_$" + _propertyName;
|
|
49 |
| |
|
50 |
1020
| op.addField(field, propertyType);
|
|
51 |
| |
|
52 |
1020
| EnhanceUtils.createSimpleAccessor(op, field, _propertyName, propertyType, _location);
|
|
53 |
| |
|
54 |
1020
| EnhanceUtils.createSimpleMutator(op, field, _propertyName, propertyType, _location);
|
|
55 |
| } |
|
56 |
| } |