1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.cubby.tags;
17
18 import java.io.IOException;
19 import java.io.StringWriter;
20
21 import javax.servlet.jsp.JspException;
22 import javax.servlet.jsp.tagext.SimpleTagSupport;
23
24 import org.seasar.framework.message.MessageFormatter;
25
26
27
28
29
30
31
32 public class ParamTag extends SimpleTagSupport {
33
34
35 private String name;
36
37
38 private String value;
39
40
41
42
43
44
45
46 public void setName(final String name) {
47 this.name = name;
48 }
49
50
51
52
53
54
55
56 public void setValue(final String value) {
57 this.value = value;
58 }
59
60
61
62
63 @Override
64 public void doTag() throws JspException, IOException {
65 final ParamParent parent = (ParamParent) findAncestorWithClass(this,
66 ParamParent.class);
67 if (parent == null) {
68 throw new JspException(MessageFormatter.getSimpleMessage(
69 "ECUB1004", null));
70 }
71 final String value;
72 if (this.value == null) {
73 StringWriter writer = new StringWriter();
74 getJspBody().invoke(writer);
75 value = writer.toString().trim();
76 } else {
77 value = this.value;
78 }
79 parent.addParameter(name, value);
80 }
81
82 }