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.tapestry.enhance.EnhanceUtils; |
18 |
| import org.apache.tapestry.enhance.EnhancementOperation; |
19 |
| import org.apache.tapestry.enhance.EnhancementWorker; |
20 |
| import org.apache.tapestry.spec.IComponentSpecification; |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| public class CreatePropertyWorker implements EnhancementWorker |
30 |
| { |
31 |
| private String _propertyName; |
32 |
| |
33 |
242
| public CreatePropertyWorker(String propertyName)
|
34 |
| { |
35 |
242
| _propertyName = propertyName;
|
36 |
| } |
37 |
| |
38 |
258
| public void performEnhancement(EnhancementOperation op, IComponentSpecification spec)
|
39 |
| { |
40 |
258
| Class propertyType = EnhanceUtils.extractPropertyType(op, _propertyName, null);
|
41 |
| |
42 |
258
| op.claimProperty(_propertyName);
|
43 |
| |
44 |
258
| String field = "_$" + _propertyName;
|
45 |
| |
46 |
258
| op.addField(field, propertyType);
|
47 |
| |
48 |
258
| EnhanceUtils.createSimpleAccessor(op, field, _propertyName, propertyType);
|
49 |
| |
50 |
258
| EnhanceUtils.createSimpleMutator(op, field, _propertyName, propertyType);
|
51 |
| } |
52 |
| } |