FileDocCategorySizeDatePackage
DateParamTagSupport.javaAPI DocGlassfish v2 API4431Sat May 05 19:17:54 BST 2007org.apache.taglibs.standard.tag.common.sql

DateParamTagSupport

public abstract class DateParamTagSupport extends javax.servlet.jsp.tagext.TagSupport

Tag handler for <Param> in JSTL, used to set parameter values for a SQL statement.

author
Justyna Horwat

Fields Summary
private static final String
TIMESTAMP_TYPE
private static final String
TIME_TYPE
private static final String
DATE_TYPE
protected String
type
protected Date
value
Constructors Summary
public DateParamTagSupport()



    //*********************************************************************
    // Constructor

      
        super();
        init();
    
Methods Summary
private voidconvertValue()


	if ((type == null) || (type.equalsIgnoreCase(TIMESTAMP_TYPE))) {
	    if (!(value instanceof java.sql.Timestamp)) {
		value = new java.sql.Timestamp(value.getTime());
	    }
	} else if (type.equalsIgnoreCase(TIME_TYPE)) {
	    if (!(value instanceof java.sql.Time)) {
		value = new java.sql.Time(value.getTime());
	    }
	} else if (type.equalsIgnoreCase(DATE_TYPE)) {
	    if (!(value instanceof java.sql.Date)) {
		value = new java.sql.Date(value.getTime());
	    }
	} else {
	    throw new JspException(
                Resources.getMessage("SQL_DATE_PARAM_INVALID_TYPE", type));
	}
    
public intdoEndTag()

	SQLExecutionTag parent = (SQLExecutionTag) 
	    findAncestorWithClass(this, SQLExecutionTag.class);
	if (parent == null) {
	    throw new JspTagException(
                Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
	}

        if (value != null) {
            convertValue();
        }

	parent.addSQLParameter(value);
	return EVAL_PAGE;
    
private voidinit()

        value = null;
        type = null;