Class WFormWidget
- Direct Known Subclasses:
WAbstractToggleButton
,WColorPicker
,WComboBox
,WEmailEdit
,WLineEdit
,WPushButton
,WSlider
,WTextArea
A WFormWidget may receive focus (see isCanReceiveFocus()
), can be disabled, and can have a label that acts as proxy for getting
focus. It provides signals which reflect changes to its value, or changes to its focus.
Form widgets also have built-in support for validation, using setValidator()
. If the validator provide
client-side validation, then an invalid validation state is reflected using the style class
"Wt-invalid"
. All validators provided by JWt implement client-side
validation.
On the server-side, use validate()
method to validate the
content using a validator previously set.
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Field Summary
Fields inherited from class eu.webtoolkit.jwt.WInteractWidget
dragTouchEndSlot_, dragTouchSlot_
-
Constructor Summary
ConstructorDescriptionCreates a WFormWidget.WFormWidget
(WContainerWidget parentContainer) Creates a WFormWidget. -
Method Summary
Modifier and TypeMethodDescriptionchanged()
Signal emitted when the value was changed.protected void
Progresses to an Ajax-enabled widget.getLabel()
Returns the label associated with this widget.Returns the placeholder text.int
Returns the tab index.Returns the validator.abstract String
Returns the current value.boolean
Returns whether the widget can receive focus.boolean
Returns whether the form element is read-only.protected void
propagateSetEnabled
(boolean enabled) Propagates that a widget was enabled or disabled through children.void
refresh()
Refresh the widget.void
remove()
Destructor.protected void
render
(EnumSet<RenderFlag> flags) Renders the widget.void
setEnabled
(boolean enabled) Sets whether the widget is enabled.void
setHidden
(boolean hidden, WAnimation animation) Sets the hidden state of this widget.void
setPlaceholderText
(CharSequence placeholderText) Sets the placeholder text.void
setReadOnly
(boolean readOnly) Sets the element read-only.void
setToolTip
(CharSequence text, TextFormat textFormat) Sets a tooltip.void
setValidator
(WValidator validator) Sets a validator for this field.abstract void
setValueText
(String value) Sets the value text.validate()
Validates the field.Signal emitted when the widget is being validated.protected void
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, getMouseOverDelay, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, setMouseOverDelay, setPopup, touchEnded, touchMoved, touchStarted, unsetDraggable
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, beingDeleted, blurred, callJavaScriptMember, childrenChanged, createDomElement, doJavaScript, escapeText, escapeText, escapeText, escapeText, find, findById, focussed, getAttributeValue, getBaseZIndex, getChildren, getClearSides, getDecorationStyle, getDomChanges, getFloatSide, getHeight, getHtmlTagName, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getScrollVisibilityMargin, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, hasFocus, hasStyleClass, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isScrollVisibilityEnabled, isScrollVisible, isSetFirstFocus, isThemeStyleEnabled, isVisible, iterateChildren, jsStringLiteral, jsStringLiteral, manageWidget, parentResized, parentResized, propagateSetVisible, removeScript, removeStyleClass, resize, scrollVisibilityChanged, setAttributeValue, setBaseZIndex, setCanReceiveFocus, setClearSides, setDecorationStyle, setDeferredToolTip, setDisabled, setFlexBox, setFloatSide, setFocus, setHiddenKeepsGeometry, setHtmlTagName, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setObjectName, setOffsets, setParentWidget, setPositionScheme, setScrollVisibilityEnabled, setScrollVisibilityMargin, setSelectable, setStyleClass, setTabIndex, setThemeStyleEnabled, setVerticalAlignment, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, setClearSides, setDeferredToolTip, setFocus, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
Methods inherited from class eu.webtoolkit.jwt.WObject
getObjectName, setFormData
-
Constructor Details
-
WFormWidget
Creates a WFormWidget. -
WFormWidget
public WFormWidget()Creates a WFormWidget.
-
-
Method Details
-
remove
public void remove()Destructor.- Overrides:
remove
in classWInteractWidget
- See Also:
-
getLabel
Returns the label associated with this widget.Returns the label (if there is one) that acts as a proxy for this widget.
- See Also:
-
setHidden
Sets the hidden state of this widget.If the widget has a label, it is hidden and shown together with this widget.
- Overrides:
setHidden
in classWWebWidget
-
getValueText
Returns the current value.This returns the current value as a string.
-
setValueText
Sets the value text.This sets the current value from a string value.
-
setValidator
Sets a validator for this field.The validator is used to validate the current input.
The default value is
null
.- See Also:
-
getValidator
Returns the validator. -
validate
Validates the field.- See Also:
-
setEnabled
public void setEnabled(boolean enabled) Sets whether the widget is enabled.A widget that is disabled cannot receive focus or user interaction.
This is the opposite of
WWebWidget#setDisabled()
. -
setReadOnly
public void setReadOnly(boolean readOnly) Sets the element read-only.A read-only form element cannot be edited, but the contents can still be selected.
By default, a form element area is not read-only.
- See Also:
-
isReadOnly
public boolean isReadOnly()Returns whether the form element is read-only.- See Also:
-
setPlaceholderText
Sets the placeholder text.This sets the text that is shown when the field is empty.
-
getPlaceholderText
Returns the placeholder text. -
changed
Signal emitted when the value was changed.For a keyboard input, the signal is only emitted when the focus is lost
-
validated
Signal emitted when the widget is being validated.This signal may be useful to react to a changed validation state.
- See Also:
-
refresh
public void refresh()Description copied from class:WWidget
Refresh the widget.The refresh method is invoked when the locale is changed using
WApplication#setLocale()
or when the user hit the refresh button.The widget must actualize its contents in response.
Note: This does not rerender the widget! Calling
refresh()
usually does not have any effect (unless you've reimplementedrefresh()
to attach to it an effect).- Overrides:
refresh
in classWWebWidget
-
setToolTip
Description copied from class:WWidget
Sets a tooltip.The tooltip is displayed when the cursor hovers over the widget.
When
textFormat
isTextFormat.XHTML
, the tooltip may contain any valid XHTML snippet. The tooltip will then be rendered using JavaScript.Note: This will set deferred tooltip to false.
- Overrides:
setToolTip
in classWWebWidget
-
isCanReceiveFocus
public boolean isCanReceiveFocus()Description copied from class:WWidget
Returns whether the widget can receive focus.- Overrides:
isCanReceiveFocus
in classWWebWidget
- See Also:
-
getTabIndex
public int getTabIndex()Description copied from class:WWidget
Returns the tab index.- Overrides:
getTabIndex
in classWWebWidget
- See Also:
-
enableAjax
protected void enableAjax()Description copied from class:WWidget
Progresses to an Ajax-enabled widget.This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.
You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.
- Overrides:
enableAjax
in classWWebWidget
- See Also:
-
validatorChanged
protected void validatorChanged() -
render
Description copied from class:WWidget
Renders the widget.This function renders the widget (or an update for the widget), after this has been scheduled using
scheduleRender()
.The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
- Overrides:
render
in classWWebWidget
-
propagateSetEnabled
protected void propagateSetEnabled(boolean enabled) Description copied from class:WWidget
Propagates that a widget was enabled or disabled through children.When enabling or disabling a widget, you usually also want to disable contained children. This method is called by
setDisabled()
to propagate its state to all children.You may want to reimplement this method if they wish to render differently when a widget is disabled. The default implementation will propagate the signal to all children.
- Overrides:
propagateSetEnabled
in classWInteractWidget
-