Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractWidget |
|
| 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 | package org.apache.tapestry.dojo; | |
15 | ||
16 | import org.apache.tapestry.AbstractComponent; | |
17 | import org.apache.tapestry.IMarkupWriter; | |
18 | import org.apache.tapestry.IRequestCycle; | |
19 | ||
20 | ||
21 | /** | |
22 | * The base widget class for all dojo related widget components. | |
23 | * | |
24 | * @author jkuhnert | |
25 | */ | |
26 | 0 | public abstract class AbstractWidget extends AbstractComponent implements IWidget |
27 | { | |
28 | ||
29 | public abstract void setDestroy(boolean destroy); | |
30 | ||
31 | /** | |
32 | * Determined dynamically at runtime during rendering, informs widget implementations | |
33 | * if they should destroy their client side widget equivalents or leave them in tact. | |
34 | * | |
35 | * @return True if the widget should be destroyed on this render, false otherwise. | |
36 | */ | |
37 | public abstract boolean getDestroy(); | |
38 | ||
39 | /** | |
40 | * {@inheritDoc} | |
41 | */ | |
42 | public void renderComponent(IMarkupWriter writer, IRequestCycle cycle) | |
43 | { | |
44 | 0 | if(!cycle.isRewinding()) { |
45 | ||
46 | 0 | if (!cycle.getResponseBuilder().isDynamic() |
47 | || cycle.getResponseBuilder().explicitlyContains(this)) { | |
48 | ||
49 | 0 | setDestroy(false); |
50 | } else { | |
51 | ||
52 | 0 | setDestroy(true); |
53 | } | |
54 | } | |
55 | ||
56 | 0 | renderWidget(writer, cycle); |
57 | 0 | } |
58 | } |