N - the type of the numberpublic class NumberTextField<N extends Number & Comparable<N>> extends TextField<N>
TextField for HTML5 <input> with type number.
Automatically validates the input against the configured min and
max attributes. If any of them is null then respective
MIN_VALUE or MAX_VALUE for the number type is used. If the number type has no minimum and/or
maximum value then Double.MIN_VALUE and Double.MAX_VALUE are used respectfully.
AbstractTextComponent.ITextFormatProvider| Modifier and Type | Field and Description |
|---|---|
static Double |
ANY
Use this as a marker of step attribute value "any"
Because the w3c spec requires step to be a non-negative digit
greater than zero we use zero as delegate for "any" keyword.
|
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATORENABLE, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING| Constructor and Description |
|---|
NumberTextField(String id)
Construct.
|
NumberTextField(String id,
IModel<N> model)
Construct.
|
NumberTextField(String id,
IModel<N> model,
Class<N> type)
Construct.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
convertInput()
Always use
Locale.ENGLISH to parse the input. |
protected String[] |
getInputTypes()
Subclass should override this method if this textfield is mapped on a different input type as
text.
|
protected String |
getModelValue()
The formatting for
Locale.ENGLISH might not be compatible with HTML (e.g. |
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag.
|
void |
onConfigure()
Called once per request on components before they are about to be rendered.
|
NumberTextField<N> |
setMaximum(N maximum)
Sets the maximum allowed value
|
NumberTextField<N> |
setMinimum(N minimum)
Sets the minimum allowed value
|
NumberTextField<N> |
setStep(N step)
Sets the step attribute
|
getConvertEmptyInputStringToNull, isInputNullable, onBeforeRender, setConvertEmptyInputStringToNulladd, add, checkRequired, clearInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModel, getModelObject, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onDetach, onDisabled, onInvalid, onRequired, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModel, setModelObject, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateCollectionModel, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrdergetLabelgetWebPage, getWebRequest, getWebResponse, getWebSessionadd, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, findComponentToDequeue, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onComponentTagBody, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildrenadd, addStateChange, afterRender, beforeRender, canCallListenerInterface, canCallListenerInterfaceAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onEvent, onModelChanged, onModelChanging, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrappublic static final Double ANY
public NumberTextField(String id)
id - component idpublic NumberTextField(String id, IModel<N> model)
id - component idmodel - the input valuepublic NumberTextField<N> setMinimum(N minimum)
minimum - the minimum allowed valuepublic NumberTextField<N> setMaximum(N maximum)
maximum - the maximum allowed valuepublic NumberTextField<N> setStep(N step)
step - the step attributepublic void onConfigure()
Component
Overrides must call super.onConfigure(), usually before any other code
NOTE: Component hierarchy should not be modified inside this method, instead it should be
done in Component.onBeforeRender()
NOTE: Why this method is preferrable to directly overriding Component.isVisible() and
Component.isEnabled()? Because those methods are called multiple times even for processing of
a single request. If they contain expensive logic they can slow down the response time of the
entire page. Further, overriding those methods directly on form components may lead to
inconsistent or unexpected state depending on when those methods are called in the form
processing workflow. It is a better practice to push changes to state rather than pull.
NOTE: If component's visibility or another property depends on another component you may call
other.configure() followed by other.isVisible() as mentioned in
Component.configure() javadoc.
NOTE: Why should Component.onBeforeRender() not be used for this? Because if a component's
visibility is controlled inside Component.onBeforeRender(), once invisible the component will
never become visible again.
onConfigure in class Componentprotected void onComponentTag(ComponentTag tag)
TextFieldonComponentTag in class TextField<N extends Number & Comparable<N>>tag - Tag to modifyComponent.onComponentTag(ComponentTag)protected String[] getInputTypes()
TextFieldgetInputTypes in class TextField<N extends Number & Comparable<N>>protected String getModelValue()
Locale.ENGLISH might not be compatible with HTML (e.g. group
digits), thus use Objects.stringValue(Object) instead.getModelValue in class FormComponent<N extends Number & Comparable<N>>protected void convertInput()
Locale.ENGLISH to parse the input.convertInput in class AbstractTextComponent<N extends Number & Comparable<N>>FormComponent.convertInput()Copyright © 2006–2014 Apache Software Foundation. All rights reserved.