1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.wml; |
16 |
| |
17 |
| import org.apache.hivemind.ApplicationRuntimeException; |
18 |
| import org.apache.hivemind.HiveMind; |
19 |
| import org.apache.tapestry.AbstractComponent; |
20 |
| import org.apache.tapestry.IMarkupWriter; |
21 |
| import org.apache.tapestry.IRequestCycle; |
22 |
| import org.apache.tapestry.Tapestry; |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| public abstract class Card extends AbstractComponent |
33 |
| { |
34 |
| private static final String ATTRIBUTE_NAME = "org.apache.tapestry.wml.Card"; |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
32
| protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
|
41 |
| { |
42 |
32
| if (cycle.getAttribute(ATTRIBUTE_NAME) != null)
|
43 |
2
| throw new ApplicationRuntimeException(Tapestry.getMessage("Card.cards-may-not-nest"),
|
44 |
| this, null, null); |
45 |
| |
46 |
30
| cycle.setAttribute(ATTRIBUTE_NAME, this);
|
47 |
| |
48 |
30
| writer.begin("card");
|
49 |
| |
50 |
30
| String title = getTitle();
|
51 |
30
| if (HiveMind.isNonBlank(title))
|
52 |
6
| writer.attribute("title", title);
|
53 |
| |
54 |
30
| renderInformalParameters(writer, cycle);
|
55 |
| |
56 |
30
| IMarkupWriter nestedWriter = writer.getNestedWriter();
|
57 |
| |
58 |
30
| renderBody(nestedWriter, cycle);
|
59 |
| |
60 |
24
| nestedWriter.close();
|
61 |
| |
62 |
24
| writer.end();
|
63 |
| |
64 |
24
| cycle.removeAttribute(ATTRIBUTE_NAME);
|
65 |
| } |
66 |
| |
67 |
| public abstract String getTitle(); |
68 |
| } |