Project Wonder 5.0

er.ajax
Class AjaxDatePicker

java.lang.Object
  extended by com.webobjects.appserver.WOElement
      extended by com.webobjects.appserver.WOComponent
          extended by er.ajax.AjaxComponent
              extended by er.ajax.AjaxDatePicker
All Implemented Interfaces:
com.webobjects.appserver.WOActionResults, com.webobjects.foundation.NSKeyValueCoding, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCodingAdditions, com.webobjects.foundation.NSValidation, IAjaxElement, java.io.Serializable, java.lang.Cloneable

public class AjaxDatePicker
extends AjaxComponent

Shameless port and adoption of Rails Date Kit. This input understands the format symbols %A, %d, %e, %b, %m, %B, %y, and %Y. See the NSTimestampFormatter for what these symbols do. This component can also understand the corresponding symbols from java.text.SimpleDateFormat. The translation from SimpleDateFormat symbols to NSTimestampFormatter symbols may have some defects.

Only one of format or formatter may be bound, if both are unbound the default of %m %d %Y is used. If format is bound, the pattern is used to create an internal formatter for validation. If formatter is bound, its pattern is extracted and used in place of format. The format/formatter is used to control the initial display in the input, the format of the value that the date picker places into the input, and validation of the input contents on form submission. The use of formatter over format is preferred for reasons of efficiency and localization.

NOTE: the AjaxDatePicker does NOT play nice with the AjaxModalDialogOpener. There is some sort of initialization conflict (I think) with Prototype that leaves you with a blank page and the browser waiting forever for something (and I have not been able to determine what it is) as soon as calendar.js loads and initialized. It will work if the page the AMD appears on explicitly loads the calendar.js in it's HEAD:

  public void appendToResponse(WOResponse response, WOContext context) {
       super.appendToResponse(response, context);
       ERXResponseRewriter.addScriptResourceInHead(response, context(), "Ajax", "calendar.js");
   }
 

See Also:
SimpleDateFormat, NSTimestampFormatter, Rails Date Kit, Serialized Form
Author:
ported by Chuck Hill
Bindings
value the value that will be shown in the input field and set by the date picker (required)
           
format the format to use in the input field (only one of format or formatter may be bound)
           
formatter the formatter to use with the input field (only one of format or formatter may be bound)
           
id HTML ID passed to the input field
           
class CSS class passed to the input field
           
style CSS style passed to the input field
           
size size attribute passed to the input field
           
maxlength maxlength attribute passed to the input field
           
name name attribute passed to the input field
           
disabled passed to the input field
           
onDateSelect JavaScript to execute when a date is selected from the calendar
           
fireEvent false if the onChange event for the input should NOT be fired when a date is selected in the calendar, defaults to true
           
dayNames list of day names (Sunday to Saturday) for localization, English is the default
           
monthNames list of month names for localization, English is the default
           
imagesDir directory to take images from, takes them from Ajax.framework by default
           
calendarCSS name of CSS resource with classed for calendar, defaults to "calendar.css"
           
calendarCSSFramework name of framework (null for application) containing calendarCSS resource, defaults to "Ajax"
           

Nested Class Summary
 
Nested classes/interfaces inherited from class com.webobjects.appserver.WOComponent
com.webobjects.appserver.WOComponent._EventLoggingEnabler, com.webobjects.appserver.WOComponent.Event
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.Null, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
com.webobjects.foundation.NSValidation._MethodBinding, com.webobjects.foundation.NSValidation._ValidationBinding, com.webobjects.foundation.NSValidation.DefaultImplementation, com.webobjects.foundation.NSValidation.Utility, com.webobjects.foundation.NSValidation.ValidationException
 
Field Summary
 
Fields inherited from class com.webobjects.appserver.WOComponent
_Extension, _IsEventLoggingEnabled, _keyAssociations
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface com.webobjects.foundation.NSValidation
_CLASS
 
Constructor Summary
AjaxDatePicker(com.webobjects.appserver.WOContext context)
           
 
Method Summary
protected  void addRequiredWebResources(com.webobjects.appserver.WOResponse response)
          Includes calendar.css and calendar.js.
 void appendToResponse(com.webobjects.appserver.WOResponse res, com.webobjects.appserver.WOContext ctx)
          Sets up AjaxOptions prior to rendering.
 void awake()
          Sets up format / formatter values.
protected  java.lang.String cssFileFrameworkName()
           
protected  java.lang.String cssFileName()
           
 java.lang.String format()
           
 java.text.Format formatter()
           
 com.webobjects.appserver.WOActionResults handleRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
          No action so nothing for us to handle.
 boolean isStateless()
           
 java.lang.String onClickScript()
           
 java.lang.String onFocusScript()
           
 com.webobjects.foundation.NSMutableDictionary options()
           
 void reset()
          Clear cached values.
 java.lang.String showCalendarScript()
           
 java.lang.String translateSimpleDateFormatSymbols(java.lang.String symbols)
          Quick and rude translation of formatting symbols from SimpleDateFormat to the symbols that this component uses.
 void validationFailedWithException(java.lang.Throwable t, java.lang.Object value, java.lang.String keyPath)
          Overridden so that parent will handle in the same manner as if this were a dynamic element.
 
Methods inherited from class er.ajax.AjaxComponent
_containerID, addScriptResourceInHead, addScriptResourceInHead, addStylesheetResourceInHead, addStylesheetResourceInHead, appendTagAttributeToResponse, booleanValueForBinding, invokeAction, safeElementID, shouldHandleRequest, valueForBinding, valueForBinding, valueForBinding
 
Methods inherited from class com.webobjects.appserver.WOComponent
_associationWithName, _awakeInContext, _childTemplate, _componentDefinition, _componentUnroll, _isPage, _setContext, _setIsPage, _setParent, _setSubcomponent, _sleepInContext, _subcomponentForElementWithID, _templateNameForClass, _unroll, application, baseURL, bindingKeys, canAccessFieldsDirectly, canGetValueForBinding, canSetValueForBinding, clone, context, debugString, descriptionForResponse, ensureAwakeInContext, frameworkName, generateResponse, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hasBinding, hasSession, isCachingEnabled, isEventLoggingEnabled, logString, name, pageWithName, parent, path, pathURL, performParentAction, pullValuesFromParent, pushValuesToParent, session, set_componentUnroll, set_unroll, setCachingEnabled, setValueForBinding, sleep, synchronizesVariablesWithBindings, takeValueForKey, takeValueForKeyPath, takeValuesFromRequest, template, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, valueForBinding, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AjaxDatePicker

public AjaxDatePicker(com.webobjects.appserver.WOContext context)
Method Detail

isStateless

public boolean isStateless()
Overrides:
isStateless in class com.webobjects.appserver.WOComponent
Returns:
true

awake

public void awake()
Sets up format / formatter values.

Overrides:
awake in class com.webobjects.appserver.WOComponent

reset

public void reset()
Clear cached values.

Overrides:
reset in class com.webobjects.appserver.WOComponent

appendToResponse

public void appendToResponse(com.webobjects.appserver.WOResponse res,
                             com.webobjects.appserver.WOContext ctx)
Sets up AjaxOptions prior to rendering.

Overrides:
appendToResponse in class AjaxComponent

onFocusScript

public java.lang.String onFocusScript()
Returns:
JavaScript for onFocus binding of HTML input

onClickScript

public java.lang.String onClickScript()
Returns:
JavaScript for onClick binding of HTML input

showCalendarScript

public java.lang.String showCalendarScript()
Returns:
JavaScript to load CSS and show calendar display

translateSimpleDateFormatSymbols

public java.lang.String translateSimpleDateFormatSymbols(java.lang.String symbols)
Quick and rude translation of formatting symbols from SimpleDateFormat to the symbols that this component uses.

Parameters:
symbols - the date format symbols to translate
Returns:
translated date format symbols

format

public java.lang.String format()
Returns:
format string used by date picker

formatter

public java.text.Format formatter()
Returns:
formatter controlling initial contents of input and validation

options

public com.webobjects.foundation.NSMutableDictionary options()
Returns:
cached Ajax options for date picker JavaScript

addRequiredWebResources

protected void addRequiredWebResources(com.webobjects.appserver.WOResponse response)
Includes calendar.css and calendar.js.

Specified by:
addRequiredWebResources in class AjaxComponent

handleRequest

public com.webobjects.appserver.WOActionResults handleRequest(com.webobjects.appserver.WORequest request,
                                                              com.webobjects.appserver.WOContext context)
No action so nothing for us to handle.

Specified by:
handleRequest in interface IAjaxElement
Specified by:
handleRequest in class AjaxComponent

validationFailedWithException

public void validationFailedWithException(java.lang.Throwable t,
                                          java.lang.Object value,
                                          java.lang.String keyPath)
Overridden so that parent will handle in the same manner as if this were a dynamic element.

Overrides:
validationFailedWithException in class com.webobjects.appserver.WOComponent

cssFileName

protected java.lang.String cssFileName()
Returns:
value for calendarCSS binding, or default of "calendar.css"

cssFileFrameworkName

protected java.lang.String cssFileFrameworkName()
Returns:
value for calendarCSSFramework binding, or default of "Ajax"

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.