%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.commons.jelly.tags.fmt.ParamTag |
|
|
1 | /* |
|
2 | * Copyright 2002,2004 The Apache Software Foundation. |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | */ |
|
16 | package org.apache.commons.jelly.tags.fmt; |
|
17 | ||
18 | import org.apache.commons.jelly.JellyTagException; |
|
19 | import org.apache.commons.jelly.XMLOutput; |
|
20 | import org.apache.commons.jelly.Tag; |
|
21 | import org.apache.commons.jelly.TagSupport; |
|
22 | import org.apache.commons.jelly.expression.Expression; |
|
23 | ||
24 | /** |
|
25 | * Support for tag handlers for <param>, the parameter setting |
|
26 | * tag in JSTL. |
|
27 | * @author <a href="mailto:willievu@yahoo.com">Willie Vu</a> |
|
28 | * @version 1.1 |
|
29 | * |
|
30 | * @task handle body content trimming |
|
31 | */ |
|
32 | 1 | public class ParamTag extends TagSupport { |
33 | ||
34 | /** Holds value of property value. */ |
|
35 | private Expression value; |
|
36 | ||
37 | /** Creates a new instance of ParamTag */ |
|
38 | 7 | public ParamTag() { |
39 | 7 | } |
40 | ||
41 | /** |
|
42 | * Evaluates this tag after all the tags properties have been initialized. |
|
43 | * |
|
44 | */ |
|
45 | public void doTag(XMLOutput output) throws JellyTagException { |
|
46 | 7 | MessageTag parent = null; |
47 | 7 | Tag t = findAncestorWithClass(this, MessageTag.class); |
48 | 7 | if (t != null) { |
49 | 7 | parent = (MessageTag) t; |
50 | } else { |
|
51 | // must be nested inside a <fmt:message> action. |
|
52 | 0 | throw new JellyTagException("must be nested inside a <fmt:message> action."); |
53 | } |
|
54 | ||
55 | 7 | Object valueInput = null; |
56 | 7 | if (this.value != null) { |
57 | 7 | valueInput = this.value.evaluate(context); |
58 | } |
|
59 | else { |
|
60 | // get value from body |
|
61 | 0 | valueInput = getBodyText(); |
62 | } |
|
63 | ||
64 | 7 | parent.addParam(valueInput); |
65 | 7 | } |
66 | ||
67 | /** Setter for property value. |
|
68 | * @param value New value of property value. |
|
69 | * |
|
70 | */ |
|
71 | public void setValue(Expression value) { |
|
72 | 7 | this.value = value; |
73 | 7 | } |
74 | ||
75 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |