org.zkoss.zul
Class Decimalbox

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.impl.NumberInputElement
                          extended by org.zkoss.zul.Decimalbox
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.sys.ComponentCtrl, Constrainted

public class Decimalbox
extends NumberInputElement

An edit box for holding BigDecimal.

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zul.impl.InputElement
InputElement.ExtraCtrl
 
Field Summary
static int AUTO
          Used with setScale(int) to denote that the scale is decided by what user has entered.
 
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
Decimalbox()
           
Decimalbox(java.math.BigDecimal value)
           
 
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).
 double doubleValue()
          Returns the value in double.
 int getScale()
          Returns the scale for the decimal number storing in this component, or AUTO if the scale is decided automatically (based on what user has entered).
 java.math.BigDecimal getValue()
          Returns the value (in BigDecimal), might be null unless a constraint stops it.
 int intValue()
          Returns the value in integer.
 long longValue()
          Returns the value in long.
 void setScale(int scale)
          Returns the scale for the decimal number storing in this component, or AUTO if the scale is decided automatically (based on what user has entered).
 void setValue(java.math.BigDecimal value)
          Sets the value (in BigDecimal).
 short shortValue()
          Returns the value in short.
 
Methods inherited from class org.zkoss.zul.impl.NumberInputElement
formatNumber, getRoundingMode, setRoundingMode, setRoundingMode, toNumberOnly
 
Methods inherited from class org.zkoss.zul.impl.FormatInputElement
getFormat, getOuterAttrs, isAsapRequired, setFormat
 
Methods inherited from class org.zkoss.zul.impl.InputElement
checkUserError, clearErrorMessage, getAreaText, getCols, getConstraint, getErrorMessage, getInnerAttrs, 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, getRealStyleFlags, 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
 

Field Detail

AUTO

public static final int AUTO
Used with setScale(int) to denote that the scale is decided by what user has entered.

See Also:
Constant Field Values
Constructor Detail

Decimalbox

public Decimalbox()

Decimalbox

public Decimalbox(java.math.BigDecimal value)
           throws org.zkoss.zk.ui.WrongValueException
Throws:
org.zkoss.zk.ui.WrongValueException
Method Detail

getValue

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

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

doubleValue

public double doubleValue()
                   throws org.zkoss.zk.ui.WrongValueException
Returns the value in double. If null, zero is returned.

Throws:
org.zkoss.zk.ui.WrongValueException

intValue

public int intValue()
             throws org.zkoss.zk.ui.WrongValueException
Returns the value in integer. If null, zero is returned.

Throws:
org.zkoss.zk.ui.WrongValueException

longValue

public long longValue()
               throws org.zkoss.zk.ui.WrongValueException
Returns the value in long. If null, zero is returned.

Throws:
org.zkoss.zk.ui.WrongValueException

shortValue

public short shortValue()
                 throws org.zkoss.zk.ui.WrongValueException
Returns the value in short. If null, zero is returned.

Throws:
org.zkoss.zk.ui.WrongValueException

setValue

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

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

getScale

public int getScale()
Returns the scale for the decimal number storing in this component, or AUTO if the scale is decided automatically (based on what user has entered).

Default: AUTO.


setScale

public void setScale(int scale)
Returns the scale for the decimal number storing in this component, or AUTO if the scale is decided automatically (based on what user has entered).

Default: AUTO.


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


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