SwatObject
└─SwatUIObject
└─SwatWidget
└─SwatControl
└─SwatInputControl
└─SwatDateEntry
public class SwatDateEntry
extends SwatInputControl
| Field Summary | |
|---|---|
| final mixed | |
| final mixed | |
| final mixed | |
| final mixed | |
| final mixed | |
| integer | Displayed date parts. |
| integer | Required date parts. |
| boolean | Whether the numeric month code is displayed in the month flydown. |
| boolean | Whether or not this time entry should auto-complete to the current date. |
| Date | End date of the valid range (exclusive). |
| Date | Start date of the valid range (inclusive). |
| Date | Date of this date entry widget. |
| Fields inherited from Swat.SwatInputControl | |
|---|---|
| required | |
| Constructor Summary | |
|---|---|
SwatDateEntry(string id) Creates a new date entry widget. |
|
| Method Summary | |
|---|---|
| private SwatCalendar | Creates the calendar widget for this date entry. |
| protected void | Creates the composite widgets used by this date entry. |
| private SwatFlydown | Creates the day flydown for this date entry. |
| private SwatFlydown | Creates the month flydown for this date entry. |
| private SwatTimeEntry | Creates the time entry widget for this date entry. |
| private SwatFlydown | Creates the year flydown for this date entry. |
| void | display() Displays this date entry. |
| protected array | Gets the array of CSS classes that are applied to this date entry widget. |
| private array | Gets the order of date parts for the current locale. |
| private string | getFormattedDate(Date date) Formats a date for this date entry. |
| protected string | Gets the inline JavaScript required for this control. |
| private string | getMonthOptionText(integer month) Gets the title of a month flydown option. |
| boolean | getState() Gets the current state of this date entry widget. |
| protected boolean | Checks if the entered date is valid with respect to the valid end date. |
| protected boolean | Checks if the entered date is valid with respect to the valid start date. |
| boolean | isValid() Checks if the entered date is within the valid range. |
| void | process() Processes this date entry. |
| void | setState(boolean state) Sets the current state of this date entry widget. |
| void | setValidRange(integer start_offset, integer end_offset) Set the valid date range. |
| protected void | Makes sure the date the user entered is within the valid range. |
| Methods inherited from Swat.SwatInputControl | |
|---|---|
| getForm, init | |
| Methods inherited from Swat.SwatControl | |
|---|---|
| addMessage, getNote, printWidgetTree | |
| Methods inherited from Swat.SwatWidget | |
|---|---|
| addCompositeWidget, addMessage, confirmCompositeWidgets, copy, createCompositeWidgets, display, displayHtmlHeadEntries, getCSSClassNames, getCompositeWidget, getCompositeWidgets, getFocusableHtmlId, getHtmlHeadEntrySet, getMessages, hasMessage, init, isDisplayed, isInitialized, isProcessed, isSensitive, printWidgetTree, process, replaceWithContainer | |
| Methods inherited from Swat.SwatUIObject | |
|---|---|
| addComment, addJavaScript, addStyleSheet, addTangoAttribution, copy, getCSSClassNames, getCSSClassString, getFirstAncestor, getHtmlHeadEntrySet, getInlineJavaScript, getUniqueId, isVisible | |
public final mixed CALENDAR = 16
public final mixed DAY = 4
public final mixed MONTH = 2
public final mixed TIME = 8
public final mixed YEAR = 1
public integer $display_parts
Displayed date parts
Bitwise combination of SwatDateEntry::YEAR,
SwatDateEntry::MONTH, SwatDateEntry::DAY,
SwatDateEntry::TIME and SwatDateEntry::CALENDAR.
For example, to show a date selector widget with just the month and year use the following:
<?php
$date->display_parts = SwatDateEntry::YEAR | SwatDateEntry::MONTH;
?>
public integer $required_parts
Required date parts
Bitwise combination of SwatDateEntry::YEAR,
SwatDateEntry::MONTH, SwatDateEntry::DAY and
SwatDateEntry::TIME.
For example, to require the month and day to be entered in a date selector widget use the following:
<?php
$date->required_parts = SwatDateEntry::MONTH | SwatDateEntry::DAY;
?>
public boolean $show_month_number = false
Whether the numeric month code is displayed in the month flydown
This is useful for credit card date entry
public boolean $use_current_date = true
Whether or not this time entry should auto-complete to the current date
public Date $valid_range_end
End date of the valid range (exclusive)
Defaults to 20 years in the future.
public Date $valid_range_start
Start date of the valid range (inclusive)
Defaults to 20 years in the past.
public Date $value = null
Date of this date entry widget
public SwatDateEntry(string id)
Creates a new date entry widget
Sets default required and display parts and sets default valid range for this date entry.
id - a non-visible unique id for this widget.private SwatCalendar createCalendar()
Creates the calendar widget for this date entry
protected void createCompositeWidgets()
Creates the composite widgets used by this date entry
private SwatFlydown createDayFlydown()
Creates the day flydown for this date entry
private SwatFlydown createMonthFlydown()
Creates the month flydown for this date entry
private SwatTimeEntry createTimeEntry()
Creates the time entry widget for this date entry
private SwatFlydown createYearFlydown()
Creates the year flydown for this date entry
public void display()
Displays this date entry
Creates internal widgets if they do not exits then displays required JavaScript, then displays internal widgets.
protected array getCSSClassNames()
Gets the array of CSS classes that are applied to this date entry widget
private array getDatePartOrder()
Gets the order of date parts for the current locale
Note: The technique used within this method does not work correcty for RTL languages that display month names, month abbreviations or weekday names. Since we're displaying months textually these locales may have date parts incorrectly ordered.
private string getFormattedDate(Date date)
Formats a date for this date entry
Returns a date string formatted according to the properties of this date entry widget. This is used primarily for returning formatted valid start and valid end dates for user error messages.
date - the date object to format.protected string getInlineJavaScript()
Gets the inline JavaScript required for this control
private string getMonthOptionText(integer month)
Gets the title of a month flydown option
month - the numeric identifier of the month.public boolean getState()
Gets the current state of this date entry widget
protected boolean isEndDateValid()
Checks if the entered date is valid with respect to the valid end date
protected boolean isStartDateValid()
Checks if the entered date is valid with respect to the valid start date
public boolean isValid()
Checks if the entered date is within the valid range
public void process()
Processes this date entry
Creates internal widgets if they do not exist and then assigns their values based on the date entered by the user. If the date is not valid, an error message is attached to this date entry.
public void setState(boolean state)
Sets the current state of this date entry widget
state - the new state of this date entry widget.public void setValidRange(integer start_offset, integer end_offset)
Set the valid date range
Convenience method to set the valid date range by year offsets.
start_offset - offset from the current year in years used to set the starting year of the valid range.end_offset - offset from the current year in years used to set the ending year of the valid range.protected void validateRanges()
Makes sure the date the user entered is within the valid range
If the date is not within the valid range, this method attaches an error message to this date entry.
A date entry widget