Package org.zkoss.zul.impl
Class NumberInputElement
java.lang.Object
org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
org.zkoss.zul.impl.InputElement
org.zkoss.zul.impl.FormatInputElement
org.zkoss.zul.impl.NumberInputElement
- All Implemented Interfaces:
Serializable,Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Disable,org.zkoss.zk.ui.ext.Readonly,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl,Constrainted
- Direct Known Subclasses:
Decimalbox,Doublebox,Doublespinner,Intbox,Longbox,Spinner
A skeletal implementation for number-type input box.
- Author:
- tomyeh
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zk.ui.HtmlBasedComponent.ExtraCtrlNested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo -
Field Summary
Fields inherited from class org.zkoss.zul.impl.InputElement
_cols, _valueFields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringformatNumber(Object value, String defaultFormat) Formats a number (Integer, BigDecimal...) into a string.protected StringReturn a default format for the number input element when the locale is specified.protected LocaleReturns the default locale, eithergetLocale()orLocales.getCurrent()(never null).Returns the locale associated with this number input element, or null ifLocales.getCurrent()is preferred.org.zkoss.zk.ui.sys.PropertyAccessgetPropertyAccess(String prop) intReturns the rounding mode.protected booleanReturns if the "locale:" inFormatInputElement.getFormat()is presented.protected voidrenderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) voidSets the locale used to identify the symbols of this number input element.voidSets the locale used to identify the symbols of this number input element.voidsetRoundingMode(int mode) Sets the rounding mode.voidsetRoundingMode(String name) Sets the rounding mode by the name.protected Object[]toNumberOnly(String val) Filters out non digit characters, such comma and whitespace, from the specified value.Methods inherited from class org.zkoss.zul.impl.FormatInputElement
getFormat, getRealFormat, setFormatMethods inherited from class org.zkoss.zul.impl.InputElement
checkUserError, clearErrorMessage, clearErrorMessage, clone, coerceFromString, coerceToString, getCols, getConstraint, getConstraintString, getErrorboxIconSclass, getErrorboxSclass, getErrorMessage, getInputAttributes, getInstant, getMaxlength, getName, getPlaceholder, getRawText, getRawValue, getTargetValue, getText, getType, isChildable, isDisabled, isInplace, isInstant, isMultiline, isReadonly, isValid, marshall, onWrongValue, select, service, setCols, setConstraint, setConstraint, setDisabled, setErrorboxIconSclass, setErrorboxSclass, setErrorMessage, setInplace, setInputAttributes, setInputAttributes, setInsertedText, setInstant, setMaxlength, setName, setPlaceholder, setRawValue, setReadonly, setSelectedText, setSelectionRange, setText, setValueDirectly, showCustomError, unmarshall, validateMethods inherited from class org.zkoss.zul.impl.XulElement
getContext, getCtrlKeys, getPopup, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Constructor Details
-
NumberInputElement
public NumberInputElement()
-
-
Method Details
-
setRoundingMode
public void setRoundingMode(int mode) Sets the rounding mode. Note: You cannot change the rounding mode unless you are using Java 6 or later.- Parameters:
mode- the rounding mode. Allowed value:BigDecimal.ROUND_CEILING,BigDecimal.ROUND_DOWN,BigDecimal.ROUND_FLOOR,BigDecimal.ROUND_HALF_DOWN,BigDecimal.ROUND_HALF_UP,BigDecimal.ROUND_HALF_EVEN,BigDecimal.ROUND_UNNECESSARYandBigDecimal.ROUND_UP- Throws:
UnsupportedOperationException- if Java 5 or below
-
setRoundingMode
Sets the rounding mode by the name. Note: You cannot change the rounding mode unless you are using Java 6 or later.- Parameters:
name- the rounding mode's name. Allowed value:- CEILING
- Rounding mode to round towards positive infinity.
- DOWN
- Rounding mode to round towards zero.
- FLOOR
- Rounding mode to round towards negative infinity.
- HALF_DOWN
- Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round down.
- HALF_EVEN
- Rounding mode to round towards the "nearest neighbor" unless both neighbors are equidistant, in which case, round towards the even neighbor.
- HALF_UP
- Rounding mode to round towards "nearest neighbor" unless both neighbors are equidistant, in which case round up.
- UNNECESSARY
- Rounding mode to assert that the requested operation has an exact result, hence no rounding is necessary.
- UP
- Rounding mode to round away from zero.
- Throws:
UnsupportedOperationException- if Java 5 or below- See Also:
-
RoundingModes
-
getRoundingMode
public int getRoundingMode()Returns the rounding mode.Default:
BigDecimal.ROUND_HALF_EVEN. -
getLocale
Returns the locale associated with this number input element, or null ifLocales.getCurrent()is preferred.- Since:
- 5.0.8
-
setLocale
Sets the locale used to identify the symbols of this number input element.Default: null (i.e.,
Locales.getCurrent(), the current locale is assumed)If the format of
FormatInputElement.getFormat()is null, the format is assumed fromgetDefaultFormat(). (since 5.0.9)- Since:
- 5.0.8
-
setLocale
Sets the locale used to identify the symbols of this number input element.Default: null (i.e.,
Locales.getCurrent(), the current locale is assumed)- Since:
- 5.0.8
-
isLocaleFormat
protected boolean isLocaleFormat()Returns if the "locale:" inFormatInputElement.getFormat()is presented.- Since:
- 9.5.1
-
getDefaultLocale
Returns the default locale, eithergetLocale()orLocales.getCurrent()(never null). It is useful when you wan to get a locale for this input.- Since:
- 5.0.10
-
renderProperties
- Overrides:
renderPropertiesin classFormatInputElement- Throws:
IOException
-
getDefaultFormat
Return a default format for the number input element when the locale is specified.Default:
##,##0.##, you can overwrite this by specifying the following setting in zk.xml<library-property> <name>org.zkoss.zul.numberFormat</name> <value>##,##0.##</value> </library-property>- Since:
- 5.0.9
- See Also:
-
formatNumber
Formats a number (Integer, BigDecimal...) into a string. If null, an empty string is returned.A utility to assist the handling of numeric data.
- Parameters:
defaultFormat- used ifFormatInputElement.getFormat()returns null. If defaultFormat andFormatInputElement.getFormat()are both null, the system's default format is used.- See Also:
-
toNumberOnly
Filters out non digit characters, such comma and whitespace, from the specified value. It is designed to let user enter data in more free style. They may or may not enter data in the specified format.- Returns:
- a two element array. The first element is the string to parse with, say, Double.parseDouble. The second element is an integer to indicate how many digits the result shall be scaled. For example, if the second element is 2. Then, the result shall be divided with 10 ^ 2.
- See Also:
-
getPropertyAccess
- Specified by:
getPropertyAccessin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
getPropertyAccessin classFormatInputElement
-