com.seajas.search.utilities.tags.MessageArgumentTag.java Source code

Java tutorial

Introduction

Here is the source code for com.seajas.search.utilities.tags.MessageArgumentTag.java

Source

/**
 * Copyright (C) 2013 Seajas, the Netherlands.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 3, as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it 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 for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.seajas.search.utilities.tags;

import javax.servlet.jsp.tagext.Tag;

import org.springframework.web.servlet.tags.HtmlEscapingAwareTag;

/**
 * Message argument tag to be used with Spring's MessageTag.
 * 
 * @author Jasper van Veghel <jasper@seajas.com>
 */
public class MessageArgumentTag extends HtmlEscapingAwareTag {
    /**
     * Serial version UID.
     */
    private static final long serialVersionUID = 0L;

    /**
     * The argument value.
     */
    private Object value;

    /**
     * Take the value and add it to the parent message arguments.
     * 
     * @return int
     */
    @Override
    protected int doStartTagInternal() {
        MessageTag parent = (MessageTag) findAncestorWithClass(this, MessageTag.class);

        parent.getArguments().add(value);

        return Tag.SKIP_BODY;
    }

    /**
     * Return the value.
     * 
     * @return Object
     */
    public Object getValue() {
        return value;
    }

    /**
     * Set the value.
     * 
     * @param value
     */
    public void setValue(final Object value) {
        this.value = value;
    }
}