eu.webtoolkit.jwt
Class WDatePicker

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WCompositeWidget
              extended by eu.webtoolkit.jwt.WDatePicker

public class WDatePicker
extends WCompositeWidget

A date picker.

A date picker shows a line edit and an icon which when clicked popups a WCalendar for editing the date. Any date entered in the line edit is reflected in the calendar, and vice-versa.

Each of these widgets may be accessed individually ( getLineEdit(), getCalendar(), and getDisplayWidget()) and there is a constructor that allows you to specify an existing line edit and display widget.

The date format used by default is "dd/MM/yyyy" and can be changed using setFormat() . At any time, the date set may be read using getDate(), or can be changed using setDate().

i18n

Internationalization of WDatePicker is mostly handled through the internationalization mechanism of WDate. The 'Close' button can be internationalized by overriding the default value for the localization key Wt.DatePicker.Close.

CSS

The date picker is styled by the current CSS theme. The look can be overridden using the Wt-datepicker and Wt-outset CSS class; the calendar itself can be styled as documented in WCalendar.

Example of a WDatePicker (default theme)

Example of a WDatePicker (default theme)

Example of a WDatePicker (polished theme)

Example of a WDatePicker (polished theme)


Constructor Summary
WDatePicker()
          Create a new date picker.
WDatePicker(WContainerWidget parent)
          Create a new date picker.
WDatePicker(WInteractWidget displayWidget, WLineEdit forEdit)
          Create a new date picker for existing line edit and with custom display widget.
WDatePicker(WInteractWidget displayWidget, WLineEdit forEdit, WContainerWidget parent)
          Create a new date picker for existing line edit and with custom display widget.
 
Method Summary
 Signal changed()
          Signal emitted when the value has changed.
 WDate getBottom()
          Returns the bottom date of the valid range.
 WCalendar getCalendar()
          The calendar widget.
 WDate getDate()
          The current date.
 WInteractWidget getDisplayWidget()
          The display widget.
 java.lang.String getFormat()
          Returns the format.
 WLineEdit getLineEdit()
          The line edit.
 WDate getTop()
          Returns the top date of the valid range.
 void remove()
          Destructor.
 void setBottom(WDate bottom)
          Sets the bottom of the valid date range.
 void setDate(WDate date)
          Sets the current date.
 void setDisabled(boolean disabled)
          Sets whether the widget is disabled.
 void setEnabled(boolean enabled)
          Sets whether the widget is enabled.
 void setFormat(java.lang.String format)
          Sets the format used for parsing or writing the date in the line edit.
 void setGlobalPopup(boolean global)
          Controls how the calendar popup is positioned.
 void setHidden(boolean hidden, WAnimation animation)
          Hide/unhide the widget.
 void setPopupVisible(boolean visible)
          Shows or hides the popup.
 void setTop(WDate top)
          Sets the top of the valid date range.
 
Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, getAttributeValue, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isVisible, load, propagateSetEnabled, refresh, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setFloatSide, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setTabIndex, setToolTip, setVerticalAlignment
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WDatePicker

public WDatePicker(WContainerWidget parent)
Create a new date picker.

This constructor creates a line edit with an icon that leads to a popup calendar. A WDateValidator is configured for the line edit.


WDatePicker

public WDatePicker()
Create a new date picker.

Calls this((WContainerWidget)null)


WDatePicker

public WDatePicker(WInteractWidget displayWidget,
                   WLineEdit forEdit,
                   WContainerWidget parent)
Create a new date picker for existing line edit and with custom display widget.

The displayWidget is a button or image which much be clicked to open the date picker. This widget will become owned by the picker.

The forEdit argument is the lineEdit that works in conjunction with the date picker. This widget does not become part of the date picker, and may be located anywhere else.


WDatePicker

public WDatePicker(WInteractWidget displayWidget,
                   WLineEdit forEdit)
Create a new date picker for existing line edit and with custom display widget.

Calls this(displayWidget, forEdit, (WContainerWidget)null)

Method Detail

remove

public void remove()
Destructor.

Overrides:
remove in class WCompositeWidget
See Also:
WContainerWidget.removeWidget(WWidget widget)

setFormat

public void setFormat(java.lang.String format)
Sets the format used for parsing or writing the date in the line edit.

Sets the format used for representing the date in the line edit. If the line edit has a WDateValidator configured for it, then also there the format is updated.

The default format is 'dd/MM/yyyy'.

See Also:
getFormat(), WDate.toString()

getFormat

public java.lang.String getFormat()
Returns the format.

See Also:
setFormat(String format)

getCalendar

public WCalendar getCalendar()
The calendar widget.

Returns the calendar widget.


getLineEdit

public WLineEdit getLineEdit()
The line edit.

Returns the line edit which works in conjunction with this date picker.


getDisplayWidget

public WInteractWidget getDisplayWidget()
The display widget.

Returns the widget which is displayed to activate the calendar.


getDate

public WDate getDate()
The current date.

Reads the current date from the getLineEdit().

Returns null if the date could not be parsed using the current getFormat().

See Also:
setDate(WDate date), WDate.fromString(String s), WLineEdit.getText()

setDate

public void setDate(WDate date)
Sets the current date.

Does nothing if the current date is Null.

See Also:
getDate()

setEnabled

public void setEnabled(boolean enabled)
Sets whether the widget is enabled.

This is the oppositie of setDisabled().


setDisabled

public void setDisabled(boolean disabled)
Description copied from class: WWidget
Sets whether the widget is disabled.

Enables or disables the widget (including all its descendant widgets). setDisabled(false) will enable this widget and all descendant widgets that are not disabled. A widget is only enabled if it and all its ancestors in the widget tree are disabled.

Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.

Overrides:
setDisabled in class WCompositeWidget
See Also:
WWidget.disable(), WWidget.enable()

setHidden

public void setHidden(boolean hidden,
                      WAnimation animation)
Hide/unhide the widget.

Overrides:
setHidden in class WCompositeWidget

setBottom

public void setBottom(WDate bottom)
Sets the bottom of the valid date range.


getBottom

public WDate getBottom()
Returns the bottom date of the valid range.


setTop

public void setTop(WDate top)
Sets the top of the valid date range.


getTop

public WDate getTop()
Returns the top date of the valid range.


changed

public Signal changed()
Signal emitted when the value has changed.

This signal is emitted when a new date has been entered (either through the line edit, or through the calendar popup).


setGlobalPopup

public void setGlobalPopup(boolean global)
Controls how the calendar popup is positioned.

When global is true, then the popup will position itself globally. This avoids that the popup is affected by enclosing parents with overflow settings that clip the popup. This makes the popup however no longer follow the popup button when this button moves.

The default is false.


setPopupVisible

public void setPopupVisible(boolean visible)
Shows or hides the popup.