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