atg.droplet
Class DateEditor

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.droplet.EmptyFormHandler
              extended by atg.droplet.GenericFormHandler
                  extended by atg.droplet.DateEditor
All Implemented Interfaces:
DropletFormHandler, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class DateEditor
extends GenericFormHandler

This class allows for the manipulation within a form of a java.util.Date property in another component.

A component created with this class should be request scoped. Therefore everytime a page with a form that uses this component will always have the current time. If you want the component to have the time at the beginning of the session, then make the component session scoped.

An example of creating a date and setting it in the java.util.Date.property follows:

 <input type="text" priority=100 bean="DateEditor.Year">
 <input type="text" priority=100 bean="DateEditor.Month">
 <input type="text" priority=100 bean="DateEditor.Day">
 <input type="text" priority=100 bean="DateEditor.Hours">
 <input type="text" priority=100 bean="DateEditor.Minutes">
 <input type="hidden" value="" bean="DateEditor.submit">
 
Note the above example assumes these date manipulation fields are within a form that calls another bean. The hidden input is to call the submit method of the DateEditor bean to ensure that the desired java.util.Date property is updated.

Another example that allows the manipulation of the current value of the java.util.Date.property follows:

 <setvalue bean="DateEditor.Date"
   value="bean:NewsRepositoryFormHandler.value.goLiveDate">

 <input type="text" priority=100 bean="DateEditor.Year">
 <input type="text" priority=100 bean="DateEditor.Month">
 <input type="text" priority=100 bean="DateEditor.Day">
 <input type="text" priority=100 bean="DateEditor.Hours">
 <input type="text" priority=100 bean="DateEditor.Minutes">
 <input type="hidden" value="" bean="DateEditor.submit">
 
NOTE: Do NOT set the properties Year, Month, Day, Hours, Minutes directly in the .properties field or using the Dynamo Developer Workbench. Do this only if you want the DateEditor always to have these values. Currently whenever the DateEditor is created it always has the current date and time.

See Also:
GenericFormHandler

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.droplet.GenericFormHandler
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
DateEditor()
          Constructs a DateEditor object with all the fields set to the current time.
 
Method Summary
 boolean checkDate(java.util.Date pDate, java.lang.String pResourceBundleName, java.util.ResourceBundle pResourceBundle)
          Checks that the date is within the required limits.
 java.lang.String getAmPm()
          Returns "AM" or "PM" depending on time.
 java.util.Date getDate()
          Returns the date expressed by all the integer component fields.
 java.lang.String getDatePropertyPathName()
          Returns the absolute path name of the Date property.
 int getDay()
          Returns property Day.
 java.util.Date getEarliestAcceptableDate()
          Returns property EarliestAcceptableDate
 int getHours()
          Returns property Hours.
 boolean getIsDateSet()
          Gets property IsDateSet
 java.util.Date getLatestAcceptableDate()
          Returns property LatestAcceptableDate.
 int getMinutes()
          Returns property Minutes
 int getMonth()
          Returns property Month.
 int getSeconds()
          Returns property Seconds
 int getYear()
          Returns the property Year.
 boolean handleSubmit(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Handles the submit transaction of a form.
 boolean isPM()
          Returns true if the time is PM.
 boolean isUsingAmPm()
          Returns property UsingAmPm.
 boolean isUsingZeroBasedMonth()
          Returns property UsingZeroBasedMonth.
static void main(java.lang.String[] args)
          Test method.
 void setAmPm(java.lang.String pAmPm)
          Sets whether the time is AM or PM.
 void setDate(java.util.Date pDate)
          Sets property Date.
 void setDatePropertyPathName(java.lang.String pDatePropertyPathName)
          Sets property DatePropertyPathName.
 void setDay(int pDay)
          Sets property Day.
 void setEarliestAcceptableDate(java.util.Date pEarliestAcceptableDate)
          Sets property EarliestAcceptableDate
 void setHours(int pHours)
          Sets property Hours.
 void setLatestAcceptableDate(java.util.Date pLatestAcceptableDate)
          Sets property LatestAcceptableDate.
 void setMinutes(int pMinutes)
          Sets property Minutes.
 void setMonth(int pMonth)
          Sets property Month.
 void setPm(boolean pPM)
          Sets the time to PM if pPM is true, otherwise sets the time to AM.
 void setSeconds(int pSeconds)
          Sets property Seconds.
 void setUsingAmPm(boolean pUsingAmPm)
          Sets property UsingAmPm.
 void setUsingZeroBasedMonth(boolean pUsingZeroBasedMonth)
          Sets property UsingZeroBasedMonth.
 void setYear(int pYear)
          Sets property Year.
 
Methods inherited from class atg.droplet.GenericFormHandler
addFormException, addUncheckedFormException, afterSet, beforeSet, checkFormRedirect, createFormSubmissionMessage, getCancelURL, getCheckForValidSession, getFormError, getFormExceptions, getFormName, getMessagePort, getMessageSource, getMessageType, getPropertyExceptions, getSendMessages, getUncheckedFormExceptions, handleCancel, handleFormException, handleUncheckedFormException, hasUncheckedFormExceptions, isDeferForwardsAndRedirects, isRestorableForm, isUseForwards, isValidSession, redirectOrForward, resetFormExceptions, setCancelURL, setCheckForValidSession, setDeferForwardsAndRedirects, setFormName, setMessagePort, setMessageSource, setMessageType, setRestorableForm, setSendMessages, setUseForwards
 
Methods inherited from class atg.droplet.EmptyFormHandler
afterGet, beforeGet
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

DateEditor

public DateEditor()
Constructs a DateEditor object with all the fields set to the current time.

Method Detail

setDatePropertyPathName

public void setDatePropertyPathName(java.lang.String pDatePropertyPathName)
Sets property DatePropertyPathName.

WARNING: Do not put the DatePropertyPathName in the JHTML file since this can allow it to be set from a client, thus exposing a security risk.

Parameters:
pDatePropertyPathName - absolute path name of the Date property

getDatePropertyPathName

public java.lang.String getDatePropertyPathName()
Returns the absolute path name of the Date property.

Returns:
absolute path name of the Date property

setDate

public void setDate(java.util.Date pDate)
Sets property Date. After setting the Date property it uses the mCalendar member to set all the integer component fields of the date and then sets the IsDateSet property to true.

Parameters:
pDate - specific instant in time, with millisecond precision

getDate

public java.util.Date getDate()
Returns the date expressed by all the integer component fields.

Returns:
date expressed by all the integer component fields

getIsDateSet

public boolean getIsDateSet()
Gets property IsDateSet

Returns:
true if the property Date is up to date; false otherwise

setYear

public void setYear(int pYear)
Sets property Year. Sets the IsDateSet property to false since the Date property is no longer up to date.

Parameters:
pYear - year value

getYear

public int getYear()
Returns the property Year.

Returns:
property Year

setMonth

public void setMonth(int pMonth)
Sets property Month. Sets the IsDateSet property to false since the Date property is no longer up to date.

Parameters:
pMonth - month value between 0-11 if UsingZeroBasedMonth is true, otherwise between 1-12

getMonth

public int getMonth()
Returns property Month. Value range is between 0-11 if UsingZeroBasedMonth property is true, otherwise the range is between 1-12.

Returns:
property Month

setDay

public void setDay(int pDay)
Sets property Day. Sets the IsDateSet property to false since the Date property is no longer up to date.

Parameters:
pDay - day value between 1-31, of course depending upon the month

getDay

public int getDay()
Returns property Day.

Returns:
property Day

setHours

public void setHours(int pHours)
Sets property Hours. Sets the IsDateSet property to false since the Date property is no longer up to date.

Parameters:
pHours - hour value between 0-23 if the UsingAmPm property is false, 1-12 otherwise

getHours

public int getHours()
Returns property Hours.

Returns:
property Hours

setMinutes

public void setMinutes(int pMinutes)
Sets property Minutes. Sets the IsDateSet property to false since the Date property is no longer up to date.

Parameters:
pMinutes - minutes value between 0-59

getMinutes

public int getMinutes()
Returns property Minutes

Returns:
property Minutes

setSeconds

public void setSeconds(int pSeconds)
Sets property Seconds. Sets the IsDateSet property to false since the Date property is no longer up to date.

Parameters:
pSeconds - seconds value between 0-59

getSeconds

public int getSeconds()
Returns property Seconds

Returns:
property Seconds

setEarliestAcceptableDate

public void setEarliestAcceptableDate(java.util.Date pEarliestAcceptableDate)
Sets property EarliestAcceptableDate

Parameters:
pEarliestAcceptableDate - earliest acceptable date in milliseconds

getEarliestAcceptableDate

public java.util.Date getEarliestAcceptableDate()
Returns property EarliestAcceptableDate

Returns:
returns earliest date that is allowed to be set in the property pointed to by DatePropertyPathName

setUsingZeroBasedMonth

public void setUsingZeroBasedMonth(boolean pUsingZeroBasedMonth)
Sets property UsingZeroBasedMonth. Default is true.

Parameters:
pUsingZeroBasedMonth - true if the Month property range is 0-11, false if it is 1-12

isUsingZeroBasedMonth

public boolean isUsingZeroBasedMonth()
Returns property UsingZeroBasedMonth.

Returns:
returns true if the Month property range is 0-11, false if the range is 1-12

setLatestAcceptableDate

public void setLatestAcceptableDate(java.util.Date pLatestAcceptableDate)
Sets property LatestAcceptableDate.

Parameters:
pLatestAcceptableDate - latest acceptable date in milliseconds

getLatestAcceptableDate

public java.util.Date getLatestAcceptableDate()
Returns property LatestAcceptableDate.

Returns:
returns latest date that is allowed to be set in the property pointed to by DatePropertyPathName

setUsingAmPm

public void setUsingAmPm(boolean pUsingAmPm)
Sets property UsingAmPm. Default is false.

Parameters:
pUsingAmPm - true if the Hours property should be interpreted with the AmPm property

isUsingAmPm

public boolean isUsingAmPm()
Returns property UsingAmPm.

Returns:
returns true if the Hours property should be interpreted with the AmPm property

setAmPm

public void setAmPm(java.lang.String pAmPm)
Sets whether the time is AM or PM. Setting this property sets the property UsingAmPm to true.

Parameters:
pAmPm - String object that is either "AM" or "PM"

getAmPm

public java.lang.String getAmPm()
Returns "AM" or "PM" depending on time.

Returns:
returns "AM" or "PM" depending on time

setPm

public void setPm(boolean pPM)
Sets the time to PM if pPM is true, otherwise sets the time to AM. Setting this property sets the property UsingAmPm to true.

Parameters:
pPM - true if "PM"; false otherwise

isPM

public boolean isPM()
Returns true if the time is PM.

Returns:
returns true if time is PM

checkDate

public boolean checkDate(java.util.Date pDate,
                         java.lang.String pResourceBundleName,
                         java.util.ResourceBundle pResourceBundle)
Checks that the date is within the required limits. If it is not it adds a form exception.

Parameters:
pDate - date to check in milliseconds
pResourceBundleName - name of the message resource bundle
pResourceBundle - message resource bundle object
Returns:
true if the date is within the required limits; false otherwise

handleSubmit

public boolean handleSubmit(DynamoHttpServletRequest pRequest,
                            DynamoHttpServletResponse pResponse)
Handles the submit transaction of a form. Sets the date entered by the user into the property pointed to by the DatePropertyPathName.

Parameters:
pRequest - request object to be processed
pResponse - response object for this request
Returns:
true if the submit transaction succeeds; false otherwise

main

public static void main(java.lang.String[] args)
Test method.

Parameters:
args - array of String arguments from the console