1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.components;
23
24 import javax.servlet.http.HttpServletRequest;
25 import javax.servlet.http.HttpServletResponse;
26
27 import org.apache.struts2.views.annotations.StrutsTag;
28 import org.apache.struts2.views.annotations.StrutsTagAttribute;
29
30 import com.opensymphony.xwork2.util.ValueStack;
31
32 /***
33 * <!-- START SNIPPET: javadoc -->
34 * Render a reset button. The reset tag is used together with the form tag to provide form resetting.
35 * The reset can have two different types of rendering:
36 * <ul>
37 * <li>input: renders as html <input type="reset"...></li>
38 * <li>button: renders as html <button type="reset"...></li>
39 * </ul>
40 * Please note that the button type has advantages by adding the possibility to seperate the submitted value from the
41 * text shown on the button face, but has issues with Microsoft Internet Explorer at least up to 6.0
42 * <!-- END SNIPPET: javadoc -->
43 *
44 * <p/> <b>Examples</b>
45 *
46 * <pre>
47 * <!-- START SNIPPET: example -->
48 * <s:reset value="Reset" />
49 * <!-- END SNIPPET: example -->
50 * </pre>
51 *
52 * <pre>
53 * <!-- START SNIPPET: example2 -->
54 * Render an button reset:
55 * <s:reset type="button" key="reset"/>
56 * <!-- END SNIPPET: example2 -->
57 * </pre>
58 *
59 */
60 @StrutsTag(
61 name="reset",
62 tldTagClass="org.apache.struts2.views.jsp.ui.ResetTag",
63 description="Render a reset button",
64 allowDynamicAttributes=true)
65 public class Reset extends FormButton {
66 final public static String TEMPLATE = "reset";
67
68 protected String action;
69 protected String method;
70 protected String align;
71 protected String type;
72
73 public Reset(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
74 super(stack, request, response);
75 }
76
77 protected String getDefaultTemplate() {
78 return Reset.TEMPLATE;
79 }
80
81 public void evaluateParams() {
82
83 if ((key == null) && (value == null)) {
84 value = "Reset";
85 }
86
87 if (((key != null)) && (value == null)) {
88 this.value = "%{getText('"+key +"')}";
89 }
90
91 super.evaluateParams();
92
93 }
94
95 /***
96 * Indicate whether the concrete button supports the type "image".
97 *
98 * @return <tt>false</tt> to indicate type image is supported.
99 */
100 protected boolean supportsImageType() {
101 return false;
102 }
103
104 @StrutsTagAttribute(description="Supply a reset button text apart from reset value. Will have no effect for " +
105 "<i>input</i> type reset, since button text will always be the value parameter.")
106 public void setLabel(String label) {
107 super.setLabel(label);
108 }
109
110 }