|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| package org.apache.tapestry.components; |
|
16 |
| |
|
17 |
| import java.text.Format; |
|
18 |
| |
|
19 |
| import org.apache.hivemind.ApplicationRuntimeException; |
|
20 |
| import org.apache.tapestry.AbstractComponent; |
|
21 |
| import org.apache.tapestry.IMarkupWriter; |
|
22 |
| import org.apache.tapestry.IRequestCycle; |
|
23 |
| |
|
24 |
| |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| public abstract class Insert extends AbstractComponent |
|
32 |
| { |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
4014
| protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
|
|
38 |
| { |
|
39 |
4014
| if (cycle.isRewinding())
|
|
40 |
81
| return;
|
|
41 |
| |
|
42 |
3933
| Object value = getValue();
|
|
43 |
| |
|
44 |
3933
| if (value == null)
|
|
45 |
12
| return;
|
|
46 |
| |
|
47 |
3921
| String insert = null;
|
|
48 |
| |
|
49 |
3921
| Format format = getFormat();
|
|
50 |
| |
|
51 |
3921
| if (format == null)
|
|
52 |
| { |
|
53 |
3915
| insert = value.toString();
|
|
54 |
| } |
|
55 |
| else |
|
56 |
| { |
|
57 |
6
| try
|
|
58 |
| { |
|
59 |
6
| insert = format.format(value);
|
|
60 |
| } |
|
61 |
| catch (Exception ex) |
|
62 |
| { |
|
63 |
3
| throw new ApplicationRuntimeException(ComponentMessages.unableToFormat(
|
|
64 |
| this, |
|
65 |
| value, |
|
66 |
| ex), this, getBinding("format").getLocation(), ex); |
|
67 |
| } |
|
68 |
| } |
|
69 |
| |
|
70 |
3918
| String styleClass = getStyleClass();
|
|
71 |
| |
|
72 |
3918
| if (styleClass != null)
|
|
73 |
| { |
|
74 |
6
| writer.begin("span");
|
|
75 |
6
| writer.attribute("class", styleClass);
|
|
76 |
| |
|
77 |
6
| renderInformalParameters(writer, cycle);
|
|
78 |
| } |
|
79 |
| |
|
80 |
3918
| writer.print(insert, getRaw());
|
|
81 |
| |
|
82 |
3918
| if (styleClass != null)
|
|
83 |
6
| writer.end();
|
|
84 |
| } |
|
85 |
| |
|
86 |
| public abstract Object getValue(); |
|
87 |
| |
|
88 |
| public abstract Format getFormat(); |
|
89 |
| |
|
90 |
| public abstract String getStyleClass(); |
|
91 |
| |
|
92 |
| public abstract boolean getRaw(); |
|
93 |
| |
|
94 |
| } |