org.zkoss.zul
Class Datebox

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.impl.InputElement
                  extended by org.zkoss.zul.impl.FormatInputElement
                      extended by org.zkoss.zul.Datebox
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.sys.ComponentCtrl, Constrainted

public class Datebox
extends FormatInputElement

An edit box for holding a date.

Default HtmlBasedComponent.getSclass(): datebox.

The default format (FormatInputElement.getFormat()) depends on JVM's setting and the current user's locale. That is, DateFormat.getDateInstance(DateFormat,DEFAULT, Locales.getCurrent). You might override getDefaultFormat() to provide your own default format.

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zul.impl.InputElement
InputElement.ExtraCtrl
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Constructor Summary
Datebox()
           
Datebox(java.util.Date date)
           
 
Method Summary
protected  java.lang.Object coerceFromString(java.lang.String value)
          Coerces the value passed to InputElement.setText(java.lang.String).
protected  java.lang.String coerceToString(java.lang.Object value)
          Coerces the value passed to InputElement.setText(java.lang.String).
protected  java.text.DateFormat getDateFormat(java.lang.String fmt)
          Returns the date format of the specified format Default: it uses SimpleDateFormat to format the date.
protected  java.lang.String getDefaultFormat()
          Returns the default format, which is used when contructing a datebox.
 java.lang.String getInnerAttrs()
          Generates the Client-Side-Action attributes to the interior tag.
 java.lang.String getOuterAttrs()
           
protected  int getRealStyleFlags()
          Returns RS_NO_WIDTH|RS_NO_HEIGHT.
 java.util.TimeZone getTimeZone()
          Returns the time zone that this date box belongs to, or null if the default time zone is used.
 java.util.Date getValue()
          Returns the value (in Date), might be null unless a constraint stops it.
 boolean isButtonVisible()
          Returns whether the button (on the right of the textbox) is visible.
 boolean isCompact()
          Returns whether to use a compact layout.
 boolean isLenient()
          Returns whether or not date/time parsing is to be lenient.
 void setButtonVisible(boolean visible)
          Sets whether the button (on the right of the textbox) is visible.
 void setCompact(boolean compact)
          Sets whether to use a compact layout.
 void setFormat(java.lang.String format)
          Sets the format.
 void setLenient(boolean lenient)
          Returns whether or not date/time parsing is to be lenient.
 void setTimeZone(java.util.TimeZone tzone)
          Sets the time zone that this date box belongs to, or null if the default time zone is used.
 void setValue(java.util.Date value)
          Sets the value (in Date).
 
Methods inherited from class org.zkoss.zul.impl.FormatInputElement
getFormat, isAsapRequired
 
Methods inherited from class org.zkoss.zul.impl.InputElement
checkUserError, clearErrorMessage, getAreaText, getCols, getConstraint, getErrorMessage, getMaxlength, getName, getRawText, getRawValue, getTabindex, getTargetValue, getText, getType, isChildable, isDisabled, isMultiline, isReadonly, isValid, newExtraCtrl, onWrongValue, select, setCols, setConstraint, setConstraint, setDisabled, setMaxlength, setName, setRawValue, setReadonly, setSelectedText, setSelectionRange, setTabindex, setText, showCustomError, validate
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getAction, getAllOnClickAttrs, getContext, getPopup, getTooltip, setAction, setContext, setPopup, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addEventListener, appendAsapAttr, focus, getDraggable, getDroppable, getHeight, getLeft, getRealStyle, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZIndex, removeEventListener, setClass, setDraggable, setDroppable, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, clone, containsVariable, detach, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getDefinition, getDesktop, getEventHandler, getExtraCtrl, getFellow, getFellowIfAny, getId, getListenerIterator, getMold, getMoldURI, getNamespace, getPage, getParent, getPropagatee, getRoot, getSpaceOwner, getUuid, getVariable, insertBefore, invalidate, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onDrawNewChild, redraw, removeAttribute, removeAttribute, removeChild, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setPage, setParent, setVariable, setVisible, smartUpdate, smartUpdate, smartUpdate, toString, unsetVariable
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Datebox

public Datebox()

Datebox

public Datebox(java.util.Date date)
        throws org.zkoss.zk.ui.WrongValueException
Throws:
org.zkoss.zk.ui.WrongValueException
Method Detail

getDefaultFormat

protected java.lang.String getDefaultFormat()
Returns the default format, which is used when contructing a datebox.

The default format (FormatInputElement.getFormat()) depends on JVM's setting and the current user's locale. That is, DateFormat.getDateInstance(DateFormat,DEFAULT, Locales.getCurrent).

You might override this method to provide your own default format.


isLenient

public boolean isLenient()
Returns whether or not date/time parsing is to be lenient.

With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match this object's format. With strict parsing, inputs must match this object's format.


setLenient

public void setLenient(boolean lenient)
Returns whether or not date/time parsing is to be lenient.

Default: true.

With lenient parsing, the parser may use heuristics to interpret inputs that do not precisely match this object's format. With strict parsing, inputs must match this object's format.


isCompact

public boolean isCompact()
Returns whether to use a compact layout.

Default: true if zh_TW or zh_CN; false otherwise.


setCompact

public void setCompact(boolean compact)
Sets whether to use a compact layout.


isButtonVisible

public boolean isButtonVisible()
Returns whether the button (on the right of the textbox) is visible.

Default: true.

Since:
2.4.1

setButtonVisible

public void setButtonVisible(boolean visible)
Sets whether the button (on the right of the textbox) is visible.

Since:
2.4.1

getValue

public java.util.Date getValue()
                        throws org.zkoss.zk.ui.WrongValueException
Returns the value (in Date), might be null unless a constraint stops it.

Throws:
org.zkoss.zk.ui.WrongValueException - if user entered a wrong value

setValue

public void setValue(java.util.Date value)
              throws org.zkoss.zk.ui.WrongValueException
Sets the value (in Date).

Throws:
org.zkoss.zk.ui.WrongValueException - if value is wrong

setFormat

public void setFormat(java.lang.String format)
               throws org.zkoss.zk.ui.WrongValueException
Description copied from class: FormatInputElement
Sets the format.

Overrides:
setFormat in class FormatInputElement
Throws:
org.zkoss.zk.ui.WrongValueException

getTimeZone

public java.util.TimeZone getTimeZone()
Returns the time zone that this date box belongs to, or null if the default time zone is used.

The default time zone is determined by TimeZones.getCurrent().


setTimeZone

public void setTimeZone(java.util.TimeZone tzone)
Sets the time zone that this date box belongs to, or null if the default time zone is used.

The default time zone is determined by TimeZones.getCurrent().


coerceFromString

protected java.lang.Object coerceFromString(java.lang.String value)
                                     throws org.zkoss.zk.ui.WrongValueException
Description copied from class: InputElement
Coerces the value passed to InputElement.setText(java.lang.String).

Deriving note:
If you want to store the value in other type, say BigDecimal, you have to override InputElement.coerceToString(java.lang.Object) and InputElement.coerceFromString(java.lang.String) to convert between a string and your targeting type.

Moreover, when Textbox is called, it calls this method with value = null. Derives shall handle this case properly.

Specified by:
coerceFromString in class InputElement
Throws:
org.zkoss.zk.ui.WrongValueException

coerceToString

protected java.lang.String coerceToString(java.lang.Object value)
Description copied from class: InputElement
Coerces the value passed to InputElement.setText(java.lang.String).

Default: convert null to an empty string.

Deriving note:
If you want to store the value in other type, say BigDecimal, you have to override InputElement.coerceToString(java.lang.Object) and InputElement.coerceFromString(java.lang.String) to convert between a string and your targeting type.

Specified by:
coerceToString in class InputElement

getDateFormat

protected java.text.DateFormat getDateFormat(java.lang.String fmt)
Returns the date format of the specified format

Default: it uses SimpleDateFormat to format the date.

Parameters:
fmt - the pattern.

getOuterAttrs

public java.lang.String getOuterAttrs()
Overrides:
getOuterAttrs in class FormatInputElement

getInnerAttrs

public java.lang.String getInnerAttrs()
Description copied from class: XulElement
Generates the Client-Side-Action attributes to the interior tag. Reason: onfocus is the main use.

Overrides:
getInnerAttrs in class InputElement

getRealStyleFlags

protected int getRealStyleFlags()
Returns RS_NO_WIDTH|RS_NO_HEIGHT.

Overrides:
getRealStyleFlags in class org.zkoss.zk.ui.HtmlBasedComponent


Copyright © 2005-2007 Potix Corporation. All Rights Reserved.