Subversion Repositories bacoAlunos

Rev

Blame | Compare with Previous | Last modification | View Log | RSS feed

package jomm.web.tags;

import org.apache.log4j.Logger;
import org.apache.struts.util.RequestUtils;

import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

public class OptionTag extends BodyTagSupport {

    private static 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(OptionTag.class);




    /**
     * Name of the bean that contains the data we will be rendering.
     */

    protected 1.5.0/docs/api/java/lang/String.html">String itemName = null;
    protected 1.5.0/docs/api/java/lang/String.html">String itemProperty = null;
    protected 1.5.0/docs/api/java/lang/String.html">String comparableObjectName = null;
    protected 1.5.0/docs/api/java/lang/String.html">String comparableObjectProperty = null;


    public 1.5.0/docs/api/java/lang/String.html">String getItemName() {
        return itemName;
    }

    public void setItemName(1.5.0/docs/api/java/lang/String.html">String itemName) {
        this.itemName = itemName;
    }

    public 1.5.0/docs/api/java/lang/String.html">String getItemProperty() {
        return itemProperty;
    }

    public void setItemProperty(1.5.0/docs/api/java/lang/String.html">String itemProperty) {
        this.itemProperty = itemProperty;
    }

    public 1.5.0/docs/api/java/lang/String.html">String getComparableObjectName() {
        return comparableObjectName;
    }

    public void setComparableObjectName(1.5.0/docs/api/java/lang/String.html">String comparableObjectName) {
        this.comparableObjectName = comparableObjectName;
    }

    public 1.5.0/docs/api/java/lang/String.html">String getComparableObjectProperty() {
        return comparableObjectProperty;
    }

    public void setComparableObjectProperty(1.5.0/docs/api/java/lang/String.html">String comparableObjectProperty) {
        this.comparableObjectProperty = comparableObjectProperty;
    }

    /**
     * The scope to be searched to retrieve the specified bean.
     */

    protected 1.5.0/docs/api/java/lang/String.html">String scope = null;

    public 1.5.0/docs/api/java/lang/String.html">String getScope() {
        return (this.scope);
    }

    public void setScope(1.5.0/docs/api/java/lang/String.html">String scope)
    {
        this.scope = scope;
    }


    public int doStartTag() throws JspException {
        return EVAL_BODY_TAG;
    }
    public int doEndTag() throws JspException {

        // Look up the requested bean (if necessary)
        5+0%2Fdocs%2Fapi+Object">Object bean = null;

        // Look up the requested property value
        5+0%2Fdocs%2Fapi+Object">Object value1 =
                RequestUtils.lookup(pageContext, itemName, itemProperty, null);
        5+0%2Fdocs%2Fapi+Object">Object value2 =
                RequestUtils.lookup(pageContext, comparableObjectName, comparableObjectProperty, null);

       
        1.5.0/docs/api/java/lang/String.html">String toPage = bodyContent.getString().trim();
        JspWriter writer = pageContext.getOut();
        try
        {
            if(value2 != null && value1.equals(value2) && bodyContent != null)
            {
                writer.write("<option selected=\"true\" value=\"" + value1.toString() + "\">");
            }
            else
            {
                writer.write("<option value=\"" + value1.toString() + "\">");
            }
            writer.write(toPage);
            writer.write("</option>");
        }
        catch(1.5.0/docs/api/java/lang/Exception.html">Exception e)
        {
            logger.error(e,e);
            throw new JspException(e);
        }
        return EVAL_PAGE;
    }
}