View Javadoc

1   /*
2    * $Id: Reset.java 451544 2006-09-30 05:38:02Z mrdon $
3    *
4    * Copyright 2006 The Apache Software Foundation.
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License");
7    * you may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    *
10   *      http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
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 &lt;input type="reset"...&gt;</li>
31   * <li>button: renders as html &lt;button type="reset"...&gt;</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   * &lt;s:reset value="%{'Reset'}" /&gt;
42   * <!-- END SNIPPET: example -->
43   * </pre>
44   *
45   * <pre>
46   * <!-- START SNIPPET: example2 -->
47   * Render an button reset:
48   * &lt;s:reset type="button" value="%{'Reset'}" label="Reset the form"/&gt;
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  }