|
|||||||||||||||||||
30 day Evaluation License registered to hlship@comcast.net Your 30 day evaluation period has expired. Please visit http://www.cenqua.com to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Card.java | 100% | 100% | 100% | 100% |
|
1 | // Copyright 2004, 2005 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // Unless required by applicable law or agreed to in writing, software | |
10 | // distributed under the License is distributed on an "AS IS" BASIS, | |
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | // See the License for the specific language governing permissions and | |
13 | // limitations under the License. | |
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 | * A deck contains a collection of cards. There is a variety of card types, each specifying a | |
26 | * different mode of user interaction. | |
27 | * | |
28 | * @author David Solis | |
29 | * @since 3.0 | |
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 | * @see AbstractComponent#renderComponent(IMarkupWriter, IRequestCycle) | |
38 | */ | |
39 | ||
40 | 16 | protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) |
41 | { | |
42 | 16 | if (cycle.getAttribute(ATTRIBUTE_NAME) != null) |
43 | 1 | throw new ApplicationRuntimeException(Tapestry.getMessage("Card.cards-may-not-nest"), |
44 | this, null, null); | |
45 | ||
46 | 15 | cycle.setAttribute(ATTRIBUTE_NAME, this); |
47 | ||
48 | 15 | writer.begin("card"); |
49 | ||
50 | 15 | String title = getTitle(); |
51 | 15 | if (HiveMind.isNonBlank(title)) |
52 | 3 | writer.attribute("title", title); |
53 | ||
54 | 15 | renderInformalParameters(writer, cycle); |
55 | ||
56 | 15 | IMarkupWriter nestedWriter = writer.getNestedWriter(); |
57 | ||
58 | 15 | renderBody(nestedWriter, cycle); |
59 | ||
60 | 12 | nestedWriter.close(); |
61 | ||
62 | 12 | writer.end(); |
63 | ||
64 | 12 | cycle.removeAttribute(ATTRIBUTE_NAME); |
65 | } | |
66 | ||
67 | public abstract String getTitle(); | |
68 | } |
|