|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.faces.component.UIComponent javax.faces.component.UIComponentBase javax.faces.component.UIOutput javax.faces.component.UIInput com.sun.rave.web.ui.component.HiddenFieldBase com.sun.rave.web.ui.component.HiddenField com.sun.rave.web.ui.component.FieldBase com.sun.rave.web.ui.component.Field com.sun.rave.web.ui.component.CalendarBase
Use the ui:calendar
when the user needs to select a
date. The calendar component displays a text field that expects a
date as input, together with an icon that when clicked displays a
small calendar. The user can either type directly into the
textfield or select a date from the calendar display.
The component renders several elements: an optional
<label>
, an <input type="text">
and an <img>
element for the icon. They are laid
out inside a HTML <table>
.
The pop-up
calendar is a complex component also laid out using a HTML
<table>
. It has child components corresponding to
<ui:dropDown>
and
<ui:iconHyperlink>
(please see these for details)
and anchors <a>
to represent the dates and the
"close" button.
ui:calendar
tag Use the selectedDate
attribute to associate the
component with a model object that represents the current value, by
setting the attribute's value to an EL expression that corresponds to
a property of a backing bean.
By default, the component accepts dates between the current date
and four years out. The years shown in the popup calendar reflect
this range. If a date outside of the range is entered into the
textfield, the component indicates a validation error. To specify
a different range of date, use the minDate
and
maxDate
attributes.
To optionally specify a label for the component, use the
label
attribute, or specify a label facet.
label
: use this facet to specify a custom
component for the label.readOnly
: use this facet to specify a custom
component for displaying the value of this component when it is
marked as readonly. The default is a ui:staticText
. In all the functions below, <id>
should be
the generated id of the TextField component.
[JSOBJECT_NAME]_setDisabled(<id>, <disabled>)
|
Enable/disable the field. Set <disabled>
to true to disable the component, or false to enable it.
|
component_setVisible(<id>)
|
Hide or show this component. |
The component gets the options from a managed bean called
CalendarBean
. The value of the component
selectedDate
is bound to a property of the managed
bean. A label for the component as a whole (label
) is
shown next to the component.
This example shows how to create a simple calendar.
<ui:calendar id="startDate" selectedDate="#{CalendarBean.startDate}" label="Start Date: " />
Code for the managed bean:
import java.io.Serializable;
import java.util.Date;
import java.util.Calendar;
import javax.faces.event.ValueChangeEvent;
public class CalendarBean {
public CalendarBean() {
}
private Date startDate = null;
public Date getStartDate() {
return this.startDate;
}
public void setStartDate(Date startDate)
{
this.startDate = startDate;
}
}
selectAll
attribute indicates that the
Add All
and Remove All
buttons should be
shown. A label for the component as a whole (label
) is shown
next to the component (labelOnTop
is false). Labels have
been specified for the list of available items and for the list of
selected items. The sorted
attribute indicates that the options on
the list will be shown in alphabetical order.
The component gets the options from a managed bean called
TravelBean
. The value of the component
selectedDate
is bound to a property
travelDate
of the managed
bean. A label for the component as a whole (label
) is
shown next to the component; the label is retrieved from a message
bundle.
The component has been configured to use a pattern for date
representation consisting of four digits for the year, two for the
month, and two for the day, separated by dashes. This pattern, set
using the dateFormatPattern
attribute will be used
regardless of locale. With this date format pattern, the default
help string will be "YYYY-MM-DD", which is suitable for English,
but not for other locales where other words are used, so a
different message is retrieved for each locale
(dateFormatPattern
).
The component is also configured to restrict the range of dates that are valid, so that the first valid date is the day after the day the component is viewed, and the last valid date is six months from that date.
<ui:calendar id="travelDate" selectedDate="#{TravelBean.travelDate}" label="#{msgs.travelDate}" dateFormatPattern="yyyy-MM-dd" dateFormatPatternHelp="#{msgs.dateFormatPattern}" minDate="#{TravelBean.tomorrowsDate}" maxDate="#{TravelBean.sixMonthsFromNow}" />
Auto-generated component class. Do NOT modify; all changes will be lost!
Field Summary |
Fields inherited from class com.sun.rave.web.ui.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 |
Constructor Summary | |
CalendarBase()
Construct a new CalendarBase . |
Method Summary | |
java.lang.String |
getDateFormatPattern()
The date format pattern to use (i.e. |
java.lang.String |
getDateFormatPatternHelp()
A message below the textfield for the date, indicating the string format to use when entering a date as text into the textfield. |
java.lang.String |
getFamily()
Return the family for this component. |
java.util.Date |
getMaxDate()
A java.util.Date object representing the last
selectable day. |
java.util.Date |
getMinDate()
A java.util.Date object representing the first
selectable day. |
java.util.Date |
getSelectedDate()
A java.util.Date object representing the currently
selected calendar date. |
java.util.TimeZone |
getTimeZone()
The java.util.TimeZone used with this
component. |
javax.faces.el.ValueBinding |
getValueBinding(java.lang.String name)
Return the ValueBinding stored for the
specified name (if any), respecting any property aliases. |
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)
The date format pattern to use (i.e. |
void |
setDateFormatPatternHelp(java.lang.String dateFormatPatternHelp)
A message below the textfield for the date, indicating the 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 |
setSelectedDate(java.util.Date selectedDate)
A java.util.Date object representing the currently
selected calendar date. |
void |
setTimeZone(java.util.TimeZone timeZone)
The java.util.TimeZone used with this
component. |
void |
setValueBinding(java.lang.String name,
javax.faces.el.ValueBinding binding)
Set the ValueBinding stored for the
specified name (if any), respecting any property
aliases. |
Methods inherited from class com.sun.rave.web.ui.component.Field |
getColumns, getLabelComponent, getPrimaryElementID, getReadOnlyComponent, log, setText |
Methods inherited from class com.sun.rave.web.ui.component.FieldBase |
getLabel, getLabelLevel, getMaxLength, getOnBlur, getOnChange, getOnClick, getOnDblClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getOnSelect, getStyle, getStyleClass, getTabIndex, getText, getToolTip, isDisabled, isReadOnly, isTrim, isVisible, setColumns, setDisabled, setLabel, setLabelLevel, setMaxLength, setOnBlur, setOnChange, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setOnSelect, setReadOnly, setStyle, setStyleClass, setTabIndex, setToolTip, setTrim, setVisible |
Methods inherited from class com.sun.rave.web.ui.component.HiddenField |
getConvertedValue, getReadOnlyValueString, getValueAsString |
Methods inherited from class javax.faces.component.UIInput |
addValidator, addValueChangeListener, broadcast, compareValues, decode, getSubmittedValue, getValidator, getValidators, getValueChangeListener, getValueChangeListeners, isImmediate, isLocalValueSet, isRequired, isValid, processDecodes, processUpdates, processValidators, removeValidator, removeValueChangeListener, setImmediate, setLocalValueSet, setRequired, setSubmittedValue, setValid, setValidator, setValue, setValueChangeListener, updateModel, validate, validateValue |
Methods inherited from class javax.faces.component.UIOutput |
getConverter, getLocalValue, getValue, setConverter |
Methods inherited from class javax.faces.component.UIComponentBase |
addFacesListener, encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacesContext, getFacesListeners, getFacet, getFacets, getFacetsAndChildren, getId, getParent, getRenderer, getRendererType, getRendersChildren, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, removeFacesListener, restoreAttachedState, saveAttachedState, setId, setParent, setRendered, setRendererType, setTransient |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.faces.component.ValueHolder |
getConverter, getLocalValue, getValue, setConverter |
Constructor Detail |
public CalendarBase()
Construct a new CalendarBase
.
Method Detail |
public java.lang.String getFamily()
Return the family for this component.
getFamily
in class FieldBase
public javax.faces.el.ValueBinding getValueBinding(java.lang.String name)
Return the ValueBinding
stored for the
specified name (if any), respecting any property aliases.
getValueBinding
in class FieldBase
name
- Name of value binding to retrievepublic void setValueBinding(java.lang.String name, javax.faces.el.ValueBinding binding)
Set the ValueBinding
stored for the
specified name (if any), respecting any property
aliases.
setValueBinding
in class FieldBase
name
- Name of value binding to setbinding
- ValueBinding to set, or null to removepublic java.lang.String getDateFormatPattern()
The date format pattern to use (i.e. yyyy-MM-dd). The
component uses an instance of
java.text.SimpleDateFormat
and you may 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 parts of time may be displayed. If a pattern is not
specified, a locale-specific default is used.
If you change the date format pattern, you may also need to
change the dateFormatPatternHelp
attribute. See the
documentation for that attribute.
public void setDateFormatPattern(java.lang.String dateFormatPattern)
The date format pattern to use (i.e. yyyy-MM-dd). The
component uses an instance of
java.text.SimpleDateFormat
and you may 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 parts of time may be displayed. If a pattern is not
specified, a locale-specific default is used.
If you change the date format pattern, you may also need to
change the dateFormatPatternHelp
attribute. See the
documentation for that attribute.
getDateFormatPattern()
public java.lang.String getDateFormatPatternHelp()
A message below the textfield for the date, indicating the string format to use when entering a date as text into the textfield.
If the dateFormatPattern
attribute has not been
set, there is no need to set this attribute, as an
appropriate locale-specific help string will be shown.
However, if the default dateFormatPattern
has
been overridden, then you may need to override this attribute
also. The default behavior of the component is to show the
pattern but capitalize it, so for example, if the value of
dateFormatPattern
is yyyy-MM-dd
,
then the default help text will be YYYY-MM-DD
.
This is likely to be inadequate for languages other than
English, in which you may use this attribute to provide
descriptions that are appropriate for each locale.
public void setDateFormatPatternHelp(java.lang.String dateFormatPatternHelp)
A message below the textfield for the date, indicating the string format to use when entering a date as text into the textfield.
If the dateFormatPattern
attribute has not been
set, there is no need to set this attribute, as an
appropriate locale-specific help string will be shown.
However, if the default dateFormatPattern
has
been overridden, then you may need to override this attribute
also. The default behavior of the component is to show the
pattern but capitalize it, so for example, if the value of
dateFormatPattern
is yyyy-MM-dd
,
then the default help text will be YYYY-MM-DD
.
This is likely to be inadequate for languages other than
English, in which you may use this attribute to provide
descriptions that are appropriate for each locale.
getDateFormatPatternHelp()
public java.util.Date getMaxDate()
A java.util.Date
object representing the last
selectable day. The default value is four 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.
public void setMaxDate(java.util.Date maxDate)
A java.util.Date
object representing the last
selectable day. The default value is four 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.
getMaxDate()
public java.util.Date getMinDate()
A java.util.Date
object representing the first
selectable day. The default value is 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 also not be able to view months before this date, or select days that precede this date. At present such dates can be selected, but will not be validated when the form is submitted.
public void setMinDate(java.util.Date minDate)
A java.util.Date
object representing the first
selectable day. The default value is 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 also not be able to view months before this date, or select days that precede this date. At present such dates can be selected, but will not be validated when the form is submitted.
getMinDate()
public java.util.Date getSelectedDate()
A java.util.Date
object representing the currently
selected calendar date.
public void setSelectedDate(java.util.Date selectedDate)
A java.util.Date
object representing the currently
selected calendar date.
getSelectedDate()
public java.util.TimeZone getTimeZone()
The java.util.TimeZone
used with this
component. Unless set, the default TimeZone for the locale in
javax.faces.component.UIViewRoot
is used.
public void setTimeZone(java.util.TimeZone timeZone)
The java.util.TimeZone
used with this
component. Unless set, the default TimeZone for the locale in
javax.faces.component.UIViewRoot
is used.
getTimeZone()
public void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
Restore the state of this component.
restoreState
in interface javax.faces.component.StateHolder
restoreState
in class FieldBase
public java.lang.Object saveState(javax.faces.context.FacesContext _context)
Save the state of this component.
saveState
in interface javax.faces.component.StateHolder
saveState
in class FieldBase
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |