001: /*
002: * $Id: Reset.java 497654 2007-01-19 00:21:57Z rgielen $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.components;
022:
023: import javax.servlet.http.HttpServletRequest;
024: import javax.servlet.http.HttpServletResponse;
025:
026: import org.apache.struts2.views.annotations.StrutsTag;
027: import org.apache.struts2.views.annotations.StrutsTagAttribute;
028:
029: import com.opensymphony.xwork2.util.ValueStack;
030:
031: /**
032: * <!-- START SNIPPET: javadoc -->
033: * Render a reset button. The reset tag is used together with the form tag to provide form resetting.
034: * The reset can have two different types of rendering:
035: * <ul>
036: * <li>input: renders as html <input type="reset"...></li>
037: * <li>button: renders as html <button type="reset"...></li>
038: * </ul>
039: * Please note that the button type has advantages by adding the possibility to seperate the submitted value from the
040: * text shown on the button face, but has issues with Microsoft Internet Explorer at least up to 6.0
041: * <!-- END SNIPPET: javadoc -->
042: *
043: * <p/> <b>Examples</b>
044: *
045: * <pre>
046: * <!-- START SNIPPET: example -->
047: * <s:reset value="Reset" />
048: * <!-- END SNIPPET: example -->
049: * </pre>
050: *
051: * <pre>
052: * <!-- START SNIPPET: example2 -->
053: * Render an button reset:
054: * <s:reset type="button" key="reset"/>
055: * <!-- END SNIPPET: example2 -->
056: * </pre>
057: *
058: */
059: @StrutsTag(name="reset",tldTagClass="org.apache.struts2.views.jsp.ui.ResetTag",description="Render a reset button")
060: public class Reset extends FormButton {
061: final public static String TEMPLATE = "reset";
062:
063: protected String action;
064: protected String method;
065: protected String align;
066: protected String type;
067:
068: public Reset(ValueStack stack, HttpServletRequest request,
069: HttpServletResponse response) {
070: super (stack, request, response);
071: }
072:
073: protected String getDefaultTemplate() {
074: return Reset.TEMPLATE;
075: }
076:
077: public void evaluateParams() {
078:
079: if ((key == null) && (value == null)) {
080: value = "Reset";
081: }
082:
083: if (((key != null)) && (value == null)) {
084: this .value = "%{getText('" + key + "')}";
085: }
086:
087: super .evaluateParams();
088:
089: }
090:
091: /**
092: * Indicate whether the concrete button supports the type "image".
093: *
094: * @return <tt>false</tt> to indicate type image is supported.
095: */
096: protected boolean supportsImageType() {
097: return false;
098: }
099:
100: @StrutsTagAttribute(description="Supply a reset button text apart from reset value. Will have no effect for " + "input type reset, since button text will always be the value parameter.")
101: public void setLabel(String label) {
102: super.setLabel(label);
103: }
104:
105: }
|