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