1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.taglib.nested.html;
19
20 import org.apache.struts.taglib.html.Constants;
21 import org.apache.struts.taglib.html.OptionsTag;
22 import org.apache.struts.taglib.nested.NestedNameSupport;
23 import org.apache.struts.taglib.nested.NestedPropertyHelper;
24
25 import javax.servlet.http.HttpServletRequest;
26 import javax.servlet.jsp.JspException;
27
28 /***
29 * NestedOptionsTag.
30 *
31 * @version $Rev: 376843 $ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
32 * $
33 * @since Struts 1.1
34 */
35 public class NestedOptionsTag extends OptionsTag implements NestedNameSupport {
36
37 private String originalName = null;
38 private String originalProperty = null;
39 private String originalLabelProperty = null;
40
41 /***
42 * Overriding method of the heart of the matter. Gets the relative
43 * property and leaves the rest up to the original tag implementation.
44 * Sweet.
45 *
46 * @return int JSP continuation directive. This is in the hands of the
47 * super class.
48 */
49 public int doStartTag() throws JspException {
50
51 originalName = getName();
52 originalProperty = getProperty();
53 originalLabelProperty = getLabelProperty();
54
55
56 HttpServletRequest request =
57 (HttpServletRequest) pageContext.getRequest();
58
59
60 if (originalLabelProperty != null) {
61
62 if ((getName() == null) || Constants.BEAN_KEY.equals(getName())) {
63 super.setLabelProperty(NestedPropertyHelper.getAdjustedProperty(
64 request, originalLabelProperty));
65 } else {
66 super.setLabelProperty(originalLabelProperty);
67 }
68 }
69
70
71 NestedPropertyHelper.setNestedProperties(request, this);
72
73
74 return super.doStartTag();
75 }
76
77 /***
78 * Complete the processing of the tag. The nested tags here will restore
79 * all the original value for the tag itself and the nesting context.
80 *
81 * @return int to describe the next step for the JSP processor
82 * @throws JspException for the bad things JSP's do
83 */
84 public int doEndTag() throws JspException {
85
86 int i = super.doEndTag();
87
88
89 setName(originalName);
90 setProperty(originalProperty);
91 setLabelProperty(originalLabelProperty);
92
93
94 return i;
95 }
96
97 /***
98 * Release the tag's resources and reset the values.
99 */
100 public void release() {
101 super.release();
102
103
104 originalName = null;
105 originalProperty = null;
106 originalLabelProperty = null;
107 }
108 }