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