All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.tapestry.contrib.valid.DateField Maven / Gradle / Ivy

There is a newer version: 4.1.6
Show newest version
// Copyright 2004, 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package org.apache.tapestry.contrib.valid;

import java.text.DateFormat;
import java.util.Date;

import org.apache.tapestry.valid.DateValidator;
import org.apache.tapestry.valid.IValidator;
import org.apache.tapestry.valid.ValidField;

/**
 * Backwards compatible version of the 1.0.7 DateField component. 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
 * 
ParameterTypeRead / WriteRequiredDefaultDescription
datejava.util.DateR / Wyes The date property to edit.
requiredbooleanRnonoIf true, then a value must be entered.
minimumjava.util.DateRno If provided, the date entered must be equal to or later than the provided minimum date. *
maximumjava.util.DateRno If provided, the date entered must be less than or equal to the provided maximum date.
displayNameStringRyes A textual name for the field that is used when formulating error messages.
format{@link DateFormat}RnoDefault format MM/dd/yyyyThe format used to display and parse dates.
displayFormat{@link String}RnoMM/DD/YYYYThe format string presented to the user if the date entered is in an incorrect format. e.g. * the format object throws a ParseException.
*

* Informal parameters are allowed. A body is not allowed. * * @author Howard Lewis Ship, Richard Lewis-Shell * @since 1.0.8 * @see ValidField */ public abstract class DateField extends ValidField { public abstract Date getDate(); public abstract void setDate(Date date); public abstract Date getMinimum(); public abstract Date getMaximum(); public abstract boolean isRequired(); public abstract DateFormat getFormat(); public abstract String getDisplayFormat(); /** * Overrides {@link ValidField#getValidator()}to construct a validator on-the-fly. */ public IValidator getValidator() { DateValidator validator = new DateValidator(); if (isParameterBound("minimum")) validator.setMinimum(getMinimum()); if (isParameterBound("maximum")) validator.setMaximum(getMaximum()); if (isParameterBound("required")) validator.setRequired(isRequired()); if (isParameterBound("format")) validator.setFormat(getFormat()); if (isParameterBound("displayFormat")) validator.setDisplayFormat(getDisplayFormat()); return validator; } /** * @see org.apache.tapestry.valid.ValidField#getValue() */ public Object getValue() { return getDate(); } /** * @see org.apache.tapestry.valid.ValidField#setValue(java.lang.Object) */ public void setValue(Object value) { setDate((Date) value); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy