Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Do |
|
| 2.0;2 |
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.HiveMind; | |
18 | import org.apache.tapestry.AbstractComponent; | |
19 | import org.apache.tapestry.IMarkupWriter; | |
20 | import org.apache.tapestry.IRequestCycle; | |
21 | ||
22 | /** | |
23 | * The do element provides a general mechanism for the user to act upon the | |
24 | * current card, in other words a card-level user interface element. The | |
25 | * representation of the do element is user agent dependent and the author must | |
26 | * only assume that the element is mapped to a unique user interface widget that | |
27 | * the user can activate. For example, the widget mapping may be to a | |
28 | * graphically rendered button, a soft or function key, a voice-activated | |
29 | * command sequence, or any other interface that has a simple "activate" | |
30 | * operation with no inter-operation persistent state. The do element may appear | |
31 | * at both the card and deck-level. | |
32 | * | |
33 | * @author David Solis | |
34 | * @since 3.0 | |
35 | */ | |
36 | ||
37 | 0 | public abstract class Do extends AbstractComponent |
38 | { | |
39 | ||
40 | /** | |
41 | * @see AbstractComponent#renderComponent(IMarkupWriter, IRequestCycle) | |
42 | */ | |
43 | ||
44 | protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) | |
45 | { | |
46 | 0 | boolean render = !cycle.isRewinding(); |
47 | ||
48 | 0 | if (render) |
49 | { | |
50 | 0 | writer.begin("do"); |
51 | ||
52 | 0 | writer.attribute("type", getType()); |
53 | ||
54 | 0 | String label = getLabel(); |
55 | 0 | if (HiveMind.isNonBlank(label)) writer.attribute("label", label); |
56 | ||
57 | 0 | renderInformalParameters(writer, cycle); |
58 | } | |
59 | ||
60 | 0 | renderBody(writer, cycle); |
61 | ||
62 | 0 | if (render) writer.end(); |
63 | 0 | } |
64 | ||
65 | public abstract String getType(); | |
66 | ||
67 | public abstract String getLabel(); | |
68 | } |