|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.Component org.apache.wicket.MarkupContainer org.apache.wicket.markup.html.WebMarkupContainer org.apache.wicket.markup.html.form.LabeledWebMarkupContainer org.apache.wicket.markup.html.form.FormComponent<T> org.apache.wicket.markup.html.form.AbstractTextComponent<T> org.apache.wicket.markup.html.form.TextField<N> org.apache.wicket.markup.html.form.NumberTextField<N>
N
- the type of the numberpublic class NumberTextField<N extends Number & Comparable<N>>
A 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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent |
---|
AbstractTextComponent.ITextFormatProvider |
Field Summary | |
---|---|
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. |
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_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER |
Constructor Summary | |
---|---|
NumberTextField(String id)
Construct. |
|
NumberTextField(String id,
Class<N> type)
Construct. |
|
NumberTextField(String id,
IModel<N> model)
Construct. |
|
NumberTextField(String id,
IModel<N> model,
Class<N> type)
Construct. |
Method Summary | |
---|---|
protected void |
convertInput()
Always use Locale.ENGLISH to parse the input. |
protected String |
getInputType()
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 |
Methods 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, 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, visitFormComponentsPostOrder |
Methods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer |
---|
getLabel |
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer |
---|
getWebPage, getWebRequest, getWebResponse, getWebSession |
Methods inherited from class org.apache.wicket.MarkupContainer |
---|
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Double ANY
Constructor Detail |
---|
public NumberTextField(String id)
id
- The component idpublic NumberTextField(String id, Class<N> type)
id
- The component idtype
- The type to use when updating the model for this text fieldpublic NumberTextField(String id, IModel<N> model)
id
- The component idmodel
- The input valuepublic NumberTextField(String id, IModel<N> model, Class<N> type)
id
- The component idmodel
- The input valuetype
- The type to use when updating the model for this text fieldMethod Detail |
---|
public NumberTextField<N> setMinimum(N minimum)
minimum
- the minimum allowed value
public NumberTextField<N> setMaximum(N maximum)
maximum
- the maximum allowed value
public NumberTextField<N> setStep(N step)
step
- the step attribute
public 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 Component
protected void onComponentTag(ComponentTag tag)
TextField
onComponentTag
in class TextField<N extends Number & Comparable<N>>
tag
- Tag to modifyComponent.onComponentTag(ComponentTag)
protected String getInputType()
TextField
getInputType
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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |