CancelTag.java :  » Development » ivatamasks » com » ivata » mask » web » tag » html » Java Open Source

Java Open Source » Development » ivatamasks 
ivatamasks » com » ivata » mask » web » tag » html » CancelTag.java
/*
 * Copyright (c) 2001 - 2005 ivata limited.
 * All rights reserved.
 * -----------------------------------------------------------------------------
 * ivata masks may be redistributed under the GNU General Public
 * License as published by the Free Software Foundation;
 * version 2 of the License.
 *
 * These programs are free software; you can redistribute them and/or
 * modify them under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2 of the License.
 *
 * These programs are distributed in the hope that they will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU General Public License in the file LICENSE.txt for more
 * details.
 *
 * If you would like a copy of the GNU General Public License write to
 *
 * Free Software Foundation, Inc.
 * 59 Temple Place - Suite 330
 * Boston, MA 02111-1307, USA.
 *
 *
 * To arrange commercial support and licensing, contact ivata at
 *                  http://www.ivata.com/contact.jsp
 * -----------------------------------------------------------------------------
 * $Log: CancelTag.java,v $
 * Revision 1.9  2005/10/11 18:54:06  colinmacleod
 * Fixed some checkstyle and javadoc issues.
 *
 * Revision 1.8  2005/10/03 10:17:25  colinmacleod
 * Fixed some style and javadoc issues.
 *
 * Revision 1.7  2005/10/02 14:06:34  colinmacleod
 * Added/improved log4j logging.
 *
 * Revision 1.6  2005/09/14 13:23:58  colinmacleod
 * Added serialVersionUID.
 *
 * Revision 1.5  2005/04/26 14:47:19  colinmacleod
 * No longer displays when printing.
 *
 * Revision 1.4  2005/04/09 18:04:20  colinmacleod
 * Changed copyright text to GPL v2 explicitly.
 *
 * Revision 1.3  2005/03/10 10:45:38  colinmacleod
 * Fixes for tomcat4. Changed setters and getters
 * to both use the same types.
 *
 * Revision 1.2  2005/01/19 13:14:03  colinmacleod
 * Renamed CausedByException to SystemException.
 *
 * Revision 1.1  2005/01/06 23:10:05  colinmacleod
 * Moved up a version number.
 * Changed copyright notices to 2005.
 * Updated the documentation:
 *   - started working on multiproject:site docu.
 *   - changed the logo.
 * Added checkstyle and fixed LOADS of style issues.
 * Added separate thirdparty subproject.
 * Added struts (in web), util and webgui (in webtheme) from ivata op.
 *
 * Revision 1.4  2004/11/03 16:12:09  colinmacleod
 * Changed fieldPath to resourceFieldPath.
 *
 * Revision 1.3  2004/07/13 19:48:10  colinmacleod
 * Moved project to POJOs from EJBs.
 * Applied PicoContainer to services layer (replacing session EJBs).
 * Applied Hibernate to persistence layer (replacing entity EJBs).
 *
 * Revision 1.2  2004/03/21 21:16:35  colinmacleod
 * Shortened name to ivata op.
 *
 * Revision 1.1.1.1  2004/01/27 20:59:38  colinmacleod
 * Moved ivata op to SourceForge.
 *
 * Revision 1.2  2003/10/16 15:43:03  jano
 * Fixes problems with building and some problems with splitting to subprojects
 *
 * Revision 1.1.1.1  2003/10/13 20:49:23  colin
 * Restructured portal into subprojects
 *
 * Revision 1.3  2003/03/03 20:53:14  colin
 * reset fieldName to cancel in doEndTag
 *
 * Revision 1.2  2003/03/03 16:57:12  colin
 * converted localization to automatic paths
 * added labels
 * added mandatory fieldName attribute
 *
 * Revision 1.1  2003/02/24 19:33:33  colin
 * Moved to new subproject.
 *
 * Revision 1.4  2003/02/24 09:49:26  colin
 * added args for i18n keys
 *
 * Revision 1.3  2003/01/30 07:52:44  colin
 * bugfixes in mandatory handling
 *
 * Revision 1.2  2003/01/27 08:26:21  colin
 * SSLEXT & i18n changes
 *
 * Revision 1.1  2003/01/18 20:32:08  colin
 * added html struts override tags and help
 * -----------------------------------------------------------------------------
 */
package com.ivata.mask.web.tag.html;

import org.apache.log4j.Logger;

import java.util.List;

import javax.servlet.jsp.JspException;
/**
 * <p>
 * Overrides an HTML <code>&lt;input type=submit&gt;</code> tag, by overriding
 * the class from <strong>Struts </strong>.
 * </p>
 *
 * <p>
 * <b>Tag attributes: </b> <br/><table cellpadding='2' cellspacing='5'
 * border='0' align='center' width='85%'>
 * <tr class='TableHeadingColor'>
 * <th>attribute</th>
 * <th>reqd.</th>
 * <th>param. class</th>
 * <th width='100%'>description</th>
 * </tr>
 * <tr>
 * <td>fieldName</td>
 * <td>true</td>
 * <td><code>java.lang.String</code></td>
 * <td>The field name is used to default the following attributes of the tag:
 * <br/>
 * <ul>
 * <li><code>styleId</code></li>
 * <li><code>titleKey</code></li>
 * <li><code>valueKey</code></li>
 * </ul>.</td>
 * </tr>
 * <tr>
 * <td>titleKey</td>
 * <td>true</td>
 * <td><code>java.lang.String</code></td>
 * <td>Specifies the localized text to use for mouse-over events.</td>
 * </tr>
 * <tr>
 * <td>valueKey</td>
 * <td>true</td>
 * <td><code>java.lang.String</code></td>
 * <td>Specifies the localized text to use for the button text.</td>
 * </tr>
 * </table>
 * </p>
 *
 * <p>
 * <b>Note: </b> all the tag attributes from {@link
 * org.apache.struts.taglib.html.CancelTag Stuts} are included.
 * </p>
 *
 * @since ivata masks 0.4 (2003-01-15)
 * @author Colin MacLeod
 * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
 * @version $Revision: 1.9 $
 */
public class CancelTag extends org.apache.struts.taglib.html.CancelTag {
    /**
     * Logger for this class.
     */
    private static final Logger logger = Logger.getLogger(CancelTag.class);

    /**
     * Serialization version (for <code>Serializable</code> interface).
     */
    private static final long serialVersionUID = 1L;
    /**
     * <p>
     * >Name of the field to which this label refers. This is used in
     * conjunction with the <code>resourceFieldPath</code> to retrieve the
     * correct message resources path.
     * </p>
     */
    private String fieldName = "cancel";
    /**
     * <p>
     * Stores and maintains <strong>ivata op </strong> specific mask properties.
     * </p>
     */
    private MaskProperties maskProperties = new MaskProperties();
    /**
     * <p>
     * Overridden to reset mask properties.
     * </p>
     *
     * @return <code>EVAL_PAGE</code> since we always want to evaluate the
     *         page after this tag.
     *
     * @throws JspException
     *             if there is an error in the mask properties.
     */
    public int doEndTag() throws JspException {
        if (logger.isDebugEnabled()) {
            logger.debug("doEndTag() - start");
        }

        // if this is read only, do nothing
        if (maskProperties.getReadOnly()
                || (pageContext.getRequest().getParameter("print") != null)) {
            maskProperties.reset(this);

            if (logger.isDebugEnabled()) {
                logger.debug("doEndTag() - end - return value = " + EVAL_PAGE);
            }
            return EVAL_PAGE;
        }
        int returnValue = super.doEndTag();
        maskProperties.reset(this);
        this.fieldName = "cancel";

        if (logger.isDebugEnabled()) {
            logger.debug("doEndTag() - end - return value = " + returnValue);
        }
        return returnValue;
    }
    /**
     * <p>
     * Overridden to set the value and title strings to the values represented
     * by the localized keys in this class.
     * </p>
     *
     * @return value returned by superclass method.
     *
     * @throws JspException
     *             if either <code>valueKey</code> or <code>titleKey</code>
     *             have not been set, or as thrown by superclass method.
     */
    public int doStartTag() throws JspException {
        if (logger.isDebugEnabled()) {
            logger.debug("doStartTag() - start");
        }

        maskProperties.setFieldName(fieldName);
        maskProperties.doStartTag(this, pageContext);
        int returnint = super.doStartTag();
        if (logger.isDebugEnabled()) {
            logger.debug("doStartTag() - end - return value = " + returnint);
        }
        return returnint;
    }
    /**
     * <copyDoc>Refer to {@link MaskProperties#getBundle}.</copyDoc>
     *
     * @return <copyDoc>Refer to {@link MaskProperties#getBundle}.</copyDoc>
     */
    public final String getBundle() {
        if (logger.isDebugEnabled()) {
            logger.debug("getBundle() - start");
        }

        String returnString = maskProperties.getBundle();
        if (logger.isDebugEnabled()) {
            logger.debug("getBundle() - end - return value = " + returnString);
        }
        return returnString;
    }
    /**
     * <p>
     * Stores and maintains <strong>ivata op </strong> specific mask properties.
     * </p>
     *
     * @return the current value of maskProperties.
     */
    public MaskProperties getMaskProperties() {
        if (logger.isDebugEnabled()) {
            logger.debug("getMaskProperties() - start");
        }

        if (logger.isDebugEnabled()) {
            logger.debug("getMaskProperties() - end - return value = "
                    + maskProperties);
        }
        return maskProperties;
    }
    /**
     * <copyDoc>Refer to {@link MaskProperties#getTitleArgs
     * MaskProperties.setTitleArgs}.</copyDoc>
     *
     * @return
     * <copyDoc>Refer to {@link MaskProperties#getTitleArgs
     * MaskProperties.setTitleArgs}.</copyDoc>
     */
    public final List getTitleArgs() {
        if (logger.isDebugEnabled()) {
            logger.debug("getTitleArgs() - start");
        }

        List returnList = maskProperties.getTitleArgs();
        if (logger.isDebugEnabled()) {
            logger.debug("getTitleArgs() - end - return value = " + returnList);
        }
        return returnList;
    }
    /**
     * <p>
     * Get the value of the key used to localize the title tag attribute.
     * </p>
     *
     * @return the current value of titleKey.
     */
    public String getTitleKey() {
        if (logger.isDebugEnabled()) {
            logger.debug("getTitleKey() - start");
        }

        String returnString = maskProperties.getTitleKey();
        if (logger.isDebugEnabled()) {
            logger
                    .debug("getTitleKey() - end - return value = "
                            + returnString);
        }
        return returnString;
    }
    /**
     * <copyDoc>Refer to {@link MaskProperties#getValueArgs
     * MaskProperties.getValueArgs}.</copyDoc>
     *
     * @return
     * <copyDoc>Refer to {@link MaskProperties#getValueArgs
     * MaskProperties.getValueArgs}.</copyDoc>
     */
    public final List getValueArgs() {
        if (logger.isDebugEnabled()) {
            logger.debug("getValueArgs() - start");
        }

        List returnList = maskProperties.getValueArgs();
        if (logger.isDebugEnabled()) {
            logger.debug("getValueArgs() - end - return value = " + returnList);
        }
        return returnList;
    }
    /**
     * <p>
     * Get the value of the key used to localize the value tag attribute.
     * </p>
     *
     * @return the current value of valueKey.
     */
    public String getValueKey() {
        if (logger.isDebugEnabled()) {
            logger.debug("getValueKey() - start");
        }

        String returnString = maskProperties.getValueKey();
        if (logger.isDebugEnabled()) {
            logger
                    .debug("getValueKey() - end - return value = "
                            + returnString);
        }
        return returnString;
    }
    /**
     * <p>
     * >Name of the field to which this label refers. This is used in
     * conjunction with the <code>resourceFieldPath</code> to retrieve the
     * correct message resources path.
     * </p>
     *
     * @param fieldNameParam
     *            the new value of fieldName.
     */
    public void setFieldName(final String fieldNameParam) {
        if (logger.isDebugEnabled()) {
            logger.debug("setFieldName(String fieldNameParam = "
                    + fieldNameParam + ") - start");
        }

        this.fieldName = fieldNameParam;

        if (logger.isDebugEnabled()) {
            logger.debug("setFieldName(String) - end");
        }
    }
    /**
     * <p>
     * Stores and maintains <strong>ivata op </strong> specific mask properties.
     * </p>
     *
     * @param maskPropertiesParam
     *            the new value of maskProperties.
     */
    public void setMaskProperties(final MaskProperties maskPropertiesParam) {
        if (logger.isDebugEnabled()) {
            logger.debug(
                    "setMaskProperties(MaskProperties maskPropertiesParam = "
                            + maskPropertiesParam + ") - start");
        }

        this.maskProperties = maskPropertiesParam;

        if (logger.isDebugEnabled()) {
            logger.debug("setMaskProperties(MaskProperties) - end");
        }
    }
    /**
     * <copyDoc>Refer to {@link MaskProperties#setTitleArgs
     * MaskProperties.setTitleArgs}.</copyDoc>
     *
     * @param args
     * <copyDoc>Refer to {@link MaskProperties#setTitleArgs
     * MaskProperties.setTitleArgs}.</copyDoc>
     */
    public final void setTitleArgs(final List args) {
        if (logger.isDebugEnabled()) {
            logger.debug("setTitleArgs(List args = " + args + ") - start");
        }

        maskProperties.setTitleArgs(args);

        if (logger.isDebugEnabled()) {
            logger.debug("setTitleArgs(List) - end");
        }
    }
    /**
     * <copyDoc>Refer to {@link MaskProperties#setTitleKey
     * MaskProperties.setTitleKey}.</copyDoc>
     *
     * @param titleKeyParam
     * <copyDoc>Refer to {@link MaskProperties#setTitleKey
     * MaskProperties.setTitleKey}.</copyDoc>
     */
    public final void setTitleKey(final String titleKeyParam) {
        if (logger.isDebugEnabled()) {
            logger.debug("setTitleKey(String titleKeyParam = " + titleKeyParam
                    + ") - start");
        }

        maskProperties.setTitleKey(titleKeyParam);

        if (logger.isDebugEnabled()) {
            logger.debug("setTitleKey(String) - end");
        }
    }
    /**
     * <copyDoc>Refer to {@link MaskProperties#setValueArgs
     * MaskProperties.setValueArgs}.</copyDoc>
     *
     * @param args
     * <copyDoc>Refer to {@link MaskProperties#setValueArgs
     * MaskProperties.setValueArgs}.</copyDoc>
     */
    public final void setValueArgs(final List args) {
        if (logger.isDebugEnabled()) {
            logger.debug("setValueArgs(List args = " + args + ") - start");
        }

        maskProperties.setValueArgs(args);

        if (logger.isDebugEnabled()) {
            logger.debug("setValueArgs(List) - end");
        }
    }
    /**
     * <p>
     * Set the value of the key used to localize the value tag attribute.
     * </p>
     *
     * @param valueKey
     *            the new value of valueKey.
     */
    public final void setValueKey(final String valueKey) {
        if (logger.isDebugEnabled()) {
            logger.debug("setValueKey(String valueKey = " + valueKey
                    + ") - start");
        }

        maskProperties.setValueKey(valueKey);

        if (logger.isDebugEnabled()) {
            logger.debug("setValueKey(String) - end");
        }
    }
}

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.