|
||||||||||
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 number typepublic 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
Double.MIN_VALUE
and Double.MAX_VALUE
are used respectfully.
Note: FormComponent.setType(Class)
must be called explicitly!
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent |
---|
AbstractTextComponent.ITextFormatProvider |
Field Summary |
---|
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,
IModel<N> model)
Construct. |
|
NumberTextField(String id,
IModel<N> model,
Class<N> type)
Construct. |
Method Summary | ||
---|---|---|
|
getConverter(Class<C> type)
Gets the converter that should be used by this component. WICKET-4501 NumberTextField<BigDecimal> renders its value in unsupported number format |
|
protected String |
getInputType()
Subclass should override this method if this textfield is mapped on a different input type as text. |
|
Locale |
getLocale()
Gets the locale for this component. WICKET-3591 Browsers support only formatting in English |
|
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 |
Methods inherited from class org.apache.wicket.markup.html.form.AbstractTextComponent |
---|
convertInput, 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, getModelValue, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isMultiPart, isRequired, isValid, newValidatable, onDetach, onDisabled, onInvalid, onValid, processChildren, processInput, remove, setConvertedInput, setLabel, setModel, setModelObject, setModelValue, setRequired, setType, shouldTrimInput, trim, updateCollectionModel, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder |
Methods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer |
---|
getLabel, setLabelInternal |
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer |
---|
getWebPage, getWebRequest |
Methods inherited from class org.apache.wicket.MarkupContainer |
---|
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, hasAssociatedMarkup, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onMarkupAttached, 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 |
Constructor Detail |
---|
public NumberTextField(String id)
id
- component idpublic NumberTextField(String id, IModel<N> model)
id
- component idmodel
- the input valuepublic NumberTextField(String id, IModel<N> model, Class<N> type)
id
- 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 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 visibility of a
component is toggled inside Component.onBeforeRender()
another method needs to be overridden
to make sure Component.onBeforeRender()
will be invoked on invisible components:
class MyComponent extends WebComponent { protected void onBeforeRender() { setVisible(Math.rand() > 0.5f); super.onBeforeRender(); } // if this override is forgotten, once invisible component will never become visible protected boolean callOnBeforeRenderIfNotVisible() { return true; } }VS
class MyComponent extends WebComponent { protected void onConfigure() { super.onConfigure(); setVisible(Math.rand() > 0.5f); } }
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>>
public Locale getLocale()
getLocale
in class Component
Session.getLocale()
public <C> IConverter<C> getConverter(Class<C> type)
getConverter
in interface IConverterLocator
getConverter
in class Component
C
- The object to convert from and to Stringtype
- The type to convert to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |