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