1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 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 public ParamTag() {
39 }
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 MessageTag parent = null;
47 Tag t = findAncestorWithClass(this, MessageTag.class);
48 if (t != null) {
49 parent = (MessageTag) t;
50 } else {
51
52 throw new JellyTagException("must be nested inside a <fmt:message> action.");
53 }
54
55 Object valueInput = null;
56 if (this.value != null) {
57 valueInput = this.value.evaluate(context);
58 }
59 else {
60
61 valueInput = getBodyText();
62 }
63
64 parent.addParam(valueInput);
65 }
66
67 /*** Setter for property value.
68 * @param value New value of property value.
69 *
70 */
71 public void setValue(Expression value) {
72 this.value = value;
73 }
74
75 }