com.sun.webui.jsf.component
Class Calendar

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIOutput
              extended by javax.faces.component.UIInput
                  extended by com.sun.webui.jsf.component.WebuiInput
                      extended by com.sun.webui.jsf.component.HiddenField
                          extended by com.sun.webui.jsf.component.Field
                              extended by com.sun.webui.jsf.component.TextField
                                  extended by com.sun.webui.jsf.component.Calendar
All Implemented Interfaces:
com.sun.webui.jsf.component.ComplexComponent, DateManager, javax.faces.component.EditableValueHolder, javax.faces.component.NamingContainer, javax.faces.component.StateHolder, javax.faces.component.ValueHolder

public class Calendar
extends TextField
implements DateManager, javax.faces.component.NamingContainer

The Calendar component is used to allow a user to select a date.


Field Summary
static java.lang.String DATE_PICKER_LINK_FACET
           
static java.lang.String PATTERN_ID
           
static java.lang.String TEXT_FIELD_FACET
           
 
Fields inherited from class com.sun.webui.jsf.component.Field
INPUT_ID, LABEL_FACET, LABEL_ID, READONLY_FACET, READONLY_ID
 
Fields inherited from class javax.faces.component.UIInput
COMPONENT_FAMILY, COMPONENT_TYPE, CONVERSION_MESSAGE_ID, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
Calendar()
          Creates a new instance of Calendar
 
Method Summary
 javax.faces.convert.Converter getConverter()
           
 java.text.DateFormat getDateFormat()
           
 java.lang.String getDateFormatPattern()
          The date format pattern to use (i.e.
 java.lang.String getDateFormatPatternHelp()
          A message located below the textfield for the date.Indicates which string format to use when entering a date as text into the textfield.
 com.sun.webui.jsf.component.CalendarMonth getDatePicker()
           
 ImageHyperlink getDatePickerLink(javax.faces.context.FacesContext context)
          Deprecated.  
 java.lang.String getFamily()
          Return the family for this component.
 java.util.Date getFirstAvailableDate()
           
 java.lang.String getJavaScriptObjectName(javax.faces.context.FacesContext context)
           
 java.lang.String getLabeledElementId(javax.faces.context.FacesContext context)
          Returns the absolute ID of an HTML element suitable for use as the value of an HTML LABEL element's for attribute.
 java.util.Date getLastAvailableDate()
           
 java.util.Date getMaxDate()
          A java.util.Date object representing the last selectable day.
 int getMaxLength()
          The maximum number of characters that can be entered for this field.
 java.util.Date getMinDate()
          A java.util.Date object representing the first selectable day.
 java.lang.String getReadOnlyValueString(javax.faces.context.FacesContext context)
          Return the value to be rendered as a string when the component is readOnly.
 java.lang.String getRendererType()
          Returns the renderer type for the component.
 java.util.Date getSelectedDate()
          A java.util.Date object representing the currently selected calendar date.
 java.lang.Object getText()
          Literal value to be rendered in this input field.
 java.util.TimeZone getTimeZone()
          The java.util.TimeZone that is used with the calendar component.
 javax.el.ValueExpression getValueExpression(java.lang.String name)
          Return the ValueExpression stored for the specified name (if any), respecting any property aliases.
 boolean isTrim()
          Flag indicating that any leading and trailing blanks will be trimmed prior to conversion to the destination data type.
 void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
          Restore the state of this component.
 java.lang.Object saveState(javax.faces.context.FacesContext _context)
          Save the state of this component.
 void setDateFormatPattern(java.lang.String dateFormatPattern)
          Update the datePicker with an explicitly set date format pattern.
 void setDateFormatPatternHelp(java.lang.String dateFormatPatternHelp)
          A message located below the textfield for the date.Indicates which string format to use when entering a date as text into the textfield.
 void setMaxDate(java.util.Date maxDate)
          A java.util.Date object representing the last selectable day.
 void setMinDate(java.util.Date minDate)
          A java.util.Date object representing the first selectable day.
 void setRequired(boolean required)
          Flag indicating that an input value for this field is mandatory, and failure to provide one will trigger a validation error.
 void setSelectedDate(java.util.Date selectedDate)
          A java.util.Date object representing the currently selected calendar date.
 void setTimeZone(java.util.TimeZone timeZone)
          Update the datePicker with an explicitly set time zone.
 void setValueExpression(java.lang.String name, javax.el.ValueExpression binding)
          Set the ValueExpression stored for the specified name (if any), respecting any property aliases.
 
Methods inherited from class com.sun.webui.jsf.component.TextField
getAutoCompleteExpression, getNotify, getValueAsString, isAutoComplete, isAutoValidate, isSubmitForm, isSubmitFormSet, processUpdates, setAutoComplete, setAutoCompleteExpression, setAutoValidate, setNotify, setSubmitForm
 
Methods inherited from class com.sun.webui.jsf.component.Field
getColumns, getFocusElementId, getIndicatorComponent, getLabel, getLabelComponent, getLabelLevel, getOnBlur, getOnChange, getOnClick, getOnDblClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getOnSelect, getPrimaryElementID, getReadOnlyComponent, getStyle, getStyleClass, getTabIndex, getToolTip, getValue, isDisabled, isReadOnly, isRequired, isVisible, setColumns, setDisabled, setLabel, setLabelLevel, setMaxLength, setOnBlur, setOnChange, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setOnSelect, setReadOnly, setStyle, setStyleClass, setTabIndex, setText, setToolTip, setTrim, setVisible
 
Methods inherited from class com.sun.webui.jsf.component.HiddenField
getHtmlTemplate, setHtmlTemplate
 
Methods inherited from class com.sun.webui.jsf.component.WebuiInput
broadcast, getValidator, getValidatorExpression, getValueChangeListener, getValueChangeListenerExpression, processDecodes, processValidators, setConverter, setId, setImmediate, setRendered, setValidatorExpression, setValueChangeListenerExpression
 
Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, decode, getConverterMessage, getRequiredMessage, getSubmittedValue, getValidatorMessage, getValidators, getValueChangeListeners, isImmediate, isLocalValueSet, isValid, removeValidator, removeValueChangeListener, resetValue, setConverterMessage, setLocalValueSet, setRequiredMessage, setSubmittedValue, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener, updateModel, validate
 
Methods inherited from class javax.faces.component.UIOutput
getLocalValue
 
Methods inherited from class javax.faces.component.UIComponentBase
encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, restoreAttachedState, saveAttachedState, setParent, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.ValueHolder
getLocalValue
 

Field Detail

DATE_PICKER_LINK_FACET

public static final java.lang.String DATE_PICKER_LINK_FACET
See Also:
Constant Field Values

PATTERN_ID

public static final java.lang.String PATTERN_ID
See Also:
Constant Field Values

TEXT_FIELD_FACET

public static final java.lang.String TEXT_FIELD_FACET
See Also:
Constant Field Values
Constructor Detail

Calendar

public Calendar()
Creates a new instance of Calendar

Method Detail

getFamily

public java.lang.String getFamily()

Return the family for this component.

Overrides:
getFamily in class TextField

getRendererType

public java.lang.String getRendererType()
Description copied from class: TextField
Returns the renderer type for the component. Depending on the type of the request, this method will return the default renderer type of "com.sun.webui.jsf.widget.TextField" in case of regular render request, or "com.sun.webui.jsf.ajax.TextField" in case of ajax request. Ajax request represents a special case of request, when partial data is rendered back to the client.

Overrides:
getRendererType in class TextField

getDatePickerLink

public ImageHyperlink getDatePickerLink(javax.faces.context.FacesContext context)
Deprecated. 

This method returns the ImageHyperlink that serves as the "button" to show or hide the calendar date picker display.

Parameters:
context - The current FacesContext.
Returns:
The ImageHyperlink to show or hide the calendar date picker.

getDatePicker

public com.sun.webui.jsf.component.CalendarMonth getDatePicker()

getJavaScriptObjectName

public java.lang.String getJavaScriptObjectName(javax.faces.context.FacesContext context)

getConverter

public javax.faces.convert.Converter getConverter()
Specified by:
getConverter in interface javax.faces.component.ValueHolder
Overrides:
getConverter in class javax.faces.component.UIOutput

getReadOnlyValueString

public java.lang.String getReadOnlyValueString(javax.faces.context.FacesContext context)
Description copied from class: HiddenField

Return the value to be rendered as a string when the component is readOnly. The default behaviour is to invoke getValueAsString(). Override this method in case a component needs specialized behaviour.

Overrides:
getReadOnlyValueString in class HiddenField
Parameters:
context - FacesContext for the current request
Returns:
A String value of the component

getDateFormat

public java.text.DateFormat getDateFormat()
Specified by:
getDateFormat in interface DateManager

getFirstAvailableDate

public java.util.Date getFirstAvailableDate()
Specified by:
getFirstAvailableDate in interface DateManager

getLastAvailableDate

public java.util.Date getLastAvailableDate()
Specified by:
getLastAvailableDate in interface DateManager

getLabeledElementId

public java.lang.String getLabeledElementId(javax.faces.context.FacesContext context)
Returns the absolute ID of an HTML element suitable for use as the value of an HTML LABEL element's for attribute. If the ComplexComponent has sub-compoents, and one of the sub-components is the target of a label, if that sub-component is a ComplexComponent, then getLabeledElementId must called on the sub-component and the value returned. The value returned by this method call may or may not resolve to a component instance.

Specified by:
getLabeledElementId in interface com.sun.webui.jsf.component.ComplexComponent
Overrides:
getLabeledElementId in class Field
Parameters:
context - The FacesContext used for the request
Returns:
An abolute id suitable for the value of an HTML LABEL element's for attribute.

setDateFormatPattern

public void setDateFormatPattern(java.lang.String dateFormatPattern)
Update the datePicker with an explicitly set date format pattern.


setTimeZone

public void setTimeZone(java.util.TimeZone timeZone)
Update the datePicker with an explicitly set time zone.


setRequired

public void setRequired(boolean required)
Flag indicating that an input value for this field is mandatory, and failure to provide one will trigger a validation error.

Specified by:
setRequired in interface javax.faces.component.EditableValueHolder
Overrides:
setRequired in class WebuiInput

getMaxLength

public int getMaxLength()
Description copied from class: Field

The maximum number of characters that can be entered for this field.

Overrides:
getMaxLength in class Field

getText

public java.lang.Object getText()
Description copied from class: Field

Literal value to be rendered in this input field. If this property is specified by a value binding expression, the corresponding value will be updated if validation succeeds.

Overrides:
getText in class Field

isTrim

public boolean isTrim()
Description copied from class: Field

Flag indicating that any leading and trailing blanks will be trimmed prior to conversion to the destination data type. Default value is true.

Overrides:
isTrim in class Field

getValueExpression

public javax.el.ValueExpression getValueExpression(java.lang.String name)

Return the ValueExpression stored for the specified name (if any), respecting any property aliases.

Overrides:
getValueExpression in class Field
Parameters:
name - Name of value binding expression to retrieve

setValueExpression

public void setValueExpression(java.lang.String name,
                               javax.el.ValueExpression binding)

Set the ValueExpression stored for the specified name (if any), respecting any property aliases.

Overrides:
setValueExpression in class Field
Parameters:
name - Name of value binding to set
binding - ValueExpression to set, or null to remove

getDateFormatPattern

public java.lang.String getDateFormatPattern()

The date format pattern to use (i.e. yyyy-MM-dd). The calendar component uses an instance of java.text.SimpleDateFormat and you can specify a pattern to be used by this component with the following restriction: the format pattern must include yyyy (not yy), MM, and dd; and no other time elements(such as seconds or minutes) may be displayed. If a pattern is not specified, a locale-specific default is used.

If you change the date format pattern, you might also need to change the dateFormatPatternHelp attribute. See the documentation for that attribute.

Specified by:
getDateFormatPattern in interface DateManager

getDateFormatPatternHelp

public java.lang.String getDateFormatPatternHelp()

A message located below the textfield for the date.Indicates which string format to use when entering a date as text into the textfield.

The calendar component internally relies on an instance of java.text.SimpleDateFormat to produce this help. The default hint is constructed by invoking the toLocalizedPattern() method on the SimpleDateFormat instance and converting this String to lower case.

Due to a bug in SimpleDateFormat, toLocalizedPattern() does not actually produce locale-appropriate strings for most locales (it works for German, but not for other locales). If the default value for the dateFormtPattern is used, the calendar component performs the localization itself, but if the default is overridden, you may need to override the hint on a per-locale basis too.


setDateFormatPatternHelp

public void setDateFormatPatternHelp(java.lang.String dateFormatPatternHelp)

A message located below the textfield for the date.Indicates which string format to use when entering a date as text into the textfield.

The calendar component internally relies on an instance of java.text.SimpleDateFormat to produce this help. The default hint is constructed by invoking the toLocalizedPattern() method on the SimpleDateFormat instance and converting this String to lower case.

Due to a bug in SimpleDateFormat, toLocalizedPattern() does not actually produce locale-appropriate strings for most locales (it works for German, but not for other locales). If the default value for the dateFormtPattern is used, the calendar component performs the localization itself, but if the default is overridden, you may need to override the hint on a per-locale basis too.

See Also:
getDateFormatPatternHelp()

getMaxDate

public java.util.Date getMaxDate()

A java.util.Date object representing the last selectable day. The default value is 200 years after the minDate (which is evaluated first).

The value of this attribute is reflected in the years that are available for selection in the month display. In future releases of this component, web application users will also not be able to view months after this date, or select days that follow this date. At present such dates can be selected, but will not be validated when the form is submitted.


setMaxDate

public void setMaxDate(java.util.Date maxDate)

A java.util.Date object representing the last selectable day. The default value is 200 years after the minDate (which is evaluated first).

The value of this attribute is reflected in the years that are available for selection in the month display. In future releases of this component, web application users will also not be able to view months after this date, or select days that follow this date. At present such dates can be selected, but will not be validated when the form is submitted.

See Also:
getMaxDate()

getMinDate

public java.util.Date getMinDate()

A java.util.Date object representing the first selectable day. The default value is 100 years prior to today's date.

The value of this attribute is reflected in the years that are available for selection in the month display. In future releases of this component, web application users will not be able to view months before this date, or select days that precede this date. At present such dates can be selected, but are not validated when the form is submitted.


setMinDate

public void setMinDate(java.util.Date minDate)

A java.util.Date object representing the first selectable day. The default value is 100 years prior to today's date.

The value of this attribute is reflected in the years that are available for selection in the month display. In future releases of this component, web application users will not be able to view months before this date, or select days that precede this date. At present such dates can be selected, but are not validated when the form is submitted.

See Also:
getMinDate()

getSelectedDate

public java.util.Date getSelectedDate()

A java.util.Date object representing the currently selected calendar date.


setSelectedDate

public void setSelectedDate(java.util.Date selectedDate)

A java.util.Date object representing the currently selected calendar date.

See Also:
getSelectedDate()

getTimeZone

public java.util.TimeZone getTimeZone()

The java.util.TimeZone that is used with the calendar component. Unless set, the default TimeZone for the locale in javax.faces.component.UIViewRoot is used.

Specified by:
getTimeZone in interface DateManager

restoreState

public void restoreState(javax.faces.context.FacesContext _context,
                         java.lang.Object _state)

Restore the state of this component.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class TextField

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext _context)

Save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class TextField


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.