Class NumberTextField<N extends Number & Comparable<N>>
- Type Parameters:
N
- the type of the number
- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IGenericComponent<N,
,FormComponent<N>> IMetadataContext<Serializable,
,Component> IFormModelUpdateListener
,IFormVisitorParticipant
,ILabelProvider<String>
,IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
- Direct Known Subclasses:
RangeTextField
TextField
for HTML5 <input> with type number.
The <input>
's value will be rendered in floating-point representation, as required by
the HTML specification. Use a simple
TextField
to use a locale specific conversion of numbers.
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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent
AbstractTextComponent.ITextFormatProvider
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Double
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.Fields inherited from class org.apache.wicket.markup.html.form.FormComponent
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATOR
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
Constructor Summary
ConstructorDescriptionConstruct.NumberTextField
(String id, Class<N> type) Construct.NumberTextField
(String id, IModel<N> model) Construct.Construct. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Always useLocale.ENGLISH
to parse the input.protected String[]
Subclass should override this method if this textfield is mapped on a different input type as text.protected String
The formatting forLocale.ENGLISH
might not be compatible with HTML (e.g. group digits), thus useObjects.stringValue(Object)
instead.protected void
Processes the component tag.protected void
Called on all components before any component is rendered.setMaximum
(N maximum) Sets the maximum allowed valuesetMaximum
(IModel<N> maximum) Sets the maximum allowed valuesetMinimum
(N minimum) Sets the minimum allowed valuesetMinimum
(IModel<N> minimum) Sets the minimum allowed valueSets the step attributeSets the step attributeMethods inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent
getConvertEmptyInputStringToNull, isInputNullable, onBeforeRender, setConvertEmptyInputStringToNull
Methods inherited from class org.apache.wicket.markup.html.form.FormComponent
add, add, checkRequired, clearInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getParameterValues, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onDetach, onDisabled, onInvalid, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateAutoLabels, updateCollectionModel, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
Methods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
getLabel
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, 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, getMarkupTag, 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, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, newMarkupSourcingStrategy, onAfterRender, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.wicket.IGenericComponent
getDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModel, setDefaultModelObject, setModel, setModelObject
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
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.
-
-
Constructor Details
-
NumberTextField
Construct.- Parameters:
id
- The component id
-
NumberTextField
Construct.- Parameters:
id
- The component idtype
- The type to use when updating the model for this text field
-
NumberTextField
Construct.- Parameters:
id
- The component idmodel
- The input value
-
NumberTextField
Construct.- Parameters:
id
- The component idmodel
- The input valuetype
- The type to use when updating the model for this text field
-
-
Method Details
-
setMinimum
Sets the minimum allowed value- Parameters:
minimum
- the minimum allowed value- Returns:
- this instance
-
setMaximum
Sets the maximum allowed value- Parameters:
maximum
- the maximum allowed value- Returns:
- this instance
-
setStep
Sets the step attribute- Parameters:
step
- the step attribute- Returns:
- this instance
-
setMinimum
Sets the minimum allowed value- Parameters:
minimum
- the minimum allowed value- Returns:
- this instance
-
setMaximum
Sets the maximum allowed value- Parameters:
maximum
- the maximum allowed value- Returns:
- this instance
-
setStep
Sets the step attribute- Parameters:
step
- the step attribute- Returns:
- this instance
-
onConfigure
Description copied from class:Component
Called on all components before any component is rendered. This method should be used to configure such things as visibility and enabled flags.Overrides must call
super.onConfigure()
, usually before any other codeNOTE: 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()
andComponent.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 byother.isVisible()
as mentioned inComponent.configure()
javadoc.NOTE: Why should
Component.onBeforeRender()
not be used for this? Because if a component's visibility is controlled insideComponent.onBeforeRender()
, once invisible the component will never become visible again.- Overrides:
onConfigure
in classComponent
-
onComponentTag
Description copied from class:TextField
Processes the component tag.- Overrides:
onComponentTag
in classTextField<N extends Number & Comparable<N>>
- Parameters:
tag
- Tag to modify- See Also:
-
getInputTypes
Description copied from class:TextField
Subclass should override this method if this textfield is mapped on a different input type as text. Like PasswordTextField or HiddenField.- Overrides:
getInputTypes
in classTextField<N extends Number & Comparable<N>>
- Returns:
- The input type of this textfield, default is null
-
getModelValue
The formatting forLocale.ENGLISH
might not be compatible with HTML (e.g. group digits), thus useObjects.stringValue(Object)
instead.- Overrides:
getModelValue
in classFormComponent<N extends Number & Comparable<N>>
- Returns:
- value
-
convertInput
Always useLocale.ENGLISH
to parse the input.- Overrides:
convertInput
in classAbstractTextComponent<N extends Number & Comparable<N>>
- See Also:
-