|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ExceptionDisplay.java | - | 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.html;
|
|
16 |
|
|
17 |
import org.apache.tapestry.BaseComponent;
|
|
18 |
import org.apache.tapestry.IMarkupWriter;
|
|
19 |
import org.apache.tapestry.IRequestCycle;
|
|
20 |
import org.apache.tapestry.bean.EvenOdd;
|
|
21 |
import org.apache.tapestry.util.exception.ExceptionDescription;
|
|
22 |
|
|
23 |
/**
|
|
24 |
* Component used to display an already formatted exception. [ <a
|
|
25 |
* href="../../../../../ComponentReference/ExceptionDisplay.html">Component Reference </a>]
|
|
26 |
*
|
|
27 |
* @author Howard Lewis Ship
|
|
28 |
*/
|
|
29 |
|
|
30 |
public abstract class ExceptionDisplay extends BaseComponent |
|
31 |
{ |
|
32 |
public abstract ExceptionDescription[] getExceptions();
|
|
33 |
|
|
34 |
private ExceptionDescription _exception;
|
|
35 |
|
|
36 |
private EvenOdd _evenOdd;
|
|
37 |
|
|
38 |
public abstract int getIndex(); |
|
39 |
|
|
40 |
public abstract int getCount(); |
|
41 |
|
|
42 |
public abstract void setCount(int count); |
|
43 |
|
|
44 |
/**
|
|
45 |
* Each time the current exception is set, as a side effect, the evenOdd helper bean is reset to
|
|
46 |
* even.
|
|
47 |
*/
|
|
48 |
|
|
49 | 32 |
public void setException(ExceptionDescription value) |
50 |
{ |
|
51 | 32 |
_exception = value; |
52 |
|
|
53 | 32 |
_evenOdd.setEven(true);
|
54 |
} |
|
55 |
|
|
56 | 118 |
public ExceptionDescription getException()
|
57 |
{ |
|
58 | 118 |
return _exception;
|
59 |
} |
|
60 |
|
|
61 | 22 |
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) |
62 |
{ |
|
63 | 22 |
ExceptionDescription[] exceptions = getExceptions(); |
64 |
|
|
65 | 22 |
setCount(exceptions.length); |
66 |
|
|
67 | 22 |
try
|
68 |
{ |
|
69 | 22 |
_evenOdd = (EvenOdd) getBeans().getBean("evenOdd");
|
70 |
|
|
71 | 22 |
super.renderComponent(writer, cycle);
|
72 |
} |
|
73 |
finally
|
|
74 |
{ |
|
75 | 22 |
_exception = null;
|
76 | 22 |
_evenOdd = null;
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 | 64 |
public boolean isLast() |
81 |
{ |
|
82 | 64 |
return getIndex() == (getCount() - 1);
|
83 |
} |
|
84 |
} |
|