1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts.taglib.nested.html;
22
23 import org.apache.struts.taglib.html.LinkTag;
24 import org.apache.struts.taglib.nested.NestedNameSupport;
25 import org.apache.struts.taglib.nested.NestedPropertyHelper;
26
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.jsp.JspException;
29
30
31
32
33
34
35
36
37 public class NestedLinkTag extends LinkTag implements NestedNameSupport {
38
39 private String origName = null;
40 private String origProperty = null;
41 private String origParamProperty = null;
42
43
44
45
46
47
48
49
50
51 public int doStartTag() throws JspException {
52 origName = super.getName();
53 origProperty = super.getProperty();
54 origParamProperty = super.getParamProperty();
55
56
57 boolean doProperty =
58 ((origProperty != null) && (origProperty.length() > 0));
59 boolean doParam =
60 ((origParamProperty != null) && (origParamProperty.length() > 0));
61
62
63 HttpServletRequest request =
64 (HttpServletRequest) pageContext.getRequest();
65
66 boolean hasName =
67 ((getName() != null) && (getName().trim().length() > 0));
68 String currentName;
69
70 if (hasName) {
71 currentName = getName();
72 } else {
73 currentName = NestedPropertyHelper.getCurrentName(request, this);
74 }
75
76
77 super.setName(currentName);
78
79
80 if (doProperty && !hasName) {
81 super.setProperty(NestedPropertyHelper.getAdjustedProperty(
82 request, origProperty));
83 }
84
85
86 if (doParam) {
87 super.setName(null);
88 super.setParamName(currentName);
89 super.setParamProperty(NestedPropertyHelper.getAdjustedProperty(
90 request, origParamProperty));
91 }
92
93
94 return super.doStartTag();
95 }
96
97
98
99
100
101
102
103
104 public int doEndTag() throws JspException {
105
106 int i = super.doEndTag();
107
108
109 setName(origName);
110 setProperty(origProperty);
111 setParamProperty(origParamProperty);
112
113
114 return i;
115 }
116
117
118
119
120 public void release() {
121 super.release();
122
123
124 origName = null;
125 origProperty = null;
126 origParamProperty = null;
127 }
128 }