Class WFormWidget
- java.lang.Object
-
- eu.webtoolkit.jwt.WObject
-
- eu.webtoolkit.jwt.WWidget
-
- eu.webtoolkit.jwt.WWebWidget
-
- eu.webtoolkit.jwt.WInteractWidget
-
- eu.webtoolkit.jwt.WFormWidget
-
- Direct Known Subclasses:
WAbstractToggleButton,WColorPicker,WComboBox,WEmailEdit,WLineEdit,WPushButton,WSlider,WTextArea
public abstract class WFormWidget extends WInteractWidget
An abstract widget that corresponds to an HTML form element.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_, noDefault
-
Fields inherited from class eu.webtoolkit.jwt.WWidget
WT_GETEXTRAMS_JS
-
-
Constructor Summary
Constructors Constructor Description WFormWidget()Creates a WFormWidget.WFormWidget(WContainerWidget parentContainer)Creates a WFormWidget.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description EventSignalchanged()Signal emitted when the value was changed.protected voidenableAjax()Progresses to an Ajax-enabled widget.WLabelgetLabel()Returns the label associated with this widget.WStringgetPlaceholderText()Returns the placeholder text.protected WValidatorgetRealValidator()intgetTabIndex()Returns the tab index.WValidatorgetValidator()Returns the validator.abstract java.lang.StringgetValueText()Returns the current value.protected booleanhasValidatorChanged()booleanisCanReceiveFocus()Returns whether the widget can receive focus.booleanisReadOnly()Returns whether the form element is read-only.protected voidpropagateSetEnabled(boolean enabled)Propagates that a widget was enabled or disabled through children.voidrefresh()Refresh the widget.voidremove()Destructor.protected voidrender(java.util.EnumSet<RenderFlag> flags)Renders the widget.voidsetEnabled(boolean enabled)Sets whether the widget is enabled.voidsetHidden(boolean hidden, WAnimation animation)Sets the hidden state of this widget.voidsetPlaceholderText(java.lang.CharSequence placeholderText)Sets the placeholder text.voidsetReadOnly(boolean readOnly)Sets the element read-only.voidsetToolTip(java.lang.CharSequence text, TextFormat textFormat)Sets a tooltip.voidsetValidator(WValidator validator)Sets a validator for this field.abstract voidsetValueText(java.lang.String value)Sets the value text.ValidationStatevalidate()Validates the field.Signal1<WValidator.Result>validated()Signal emitted when the widget is being validated.protected voidvalidatorChanged()-
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, hideToolTip, 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, showToolTip, showToolTipOnHover, unescapeText, updateSignalConnection, voidEventSignal, widgetAdded, widgetRemoved
-
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addJSignal, addStyleClass, animateHide, animateShow, applyThemeStyles, boxBorder, boxPadding, createJavaScript, disable, dropEvent, enable, getDropTouch, getJsRef, getParent, hide, htmlText, isExposed, isGlobalWidget, isLayoutSizeAware, layoutSizeChanged, needsRerender, positionAt, positionAt, positionAt, positionAt, removeFromParent, removeStyleClass, removeWidget, render, resize, scheduleRender, scheduleRender, scheduleRender, scheduleThemeStyleApply, 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 Detail
-
WFormWidget
public WFormWidget(WContainerWidget parentContainer)
Creates a WFormWidget.
-
WFormWidget
public WFormWidget()
Creates a WFormWidget.
-
-
Method Detail
-
remove
public void remove()
Destructor.- Overrides:
removein classWInteractWidget- See Also:
WWidget.removeWidget(WWidget widget)
-
getLabel
public WLabel 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:
WLabel.setBuddy(WFormWidget buddy)
-
setHidden
public void setHidden(boolean hidden, WAnimation animation)Sets the hidden state of this widget.If the widget has a label, it is hidden and shown together with this widget.
- Overrides:
setHiddenin classWWebWidget
-
getValueText
public abstract java.lang.String getValueText()
Returns the current value.This returns the current value as a string.
-
setValueText
public abstract void setValueText(java.lang.String value)
Sets the value text.This sets the current value from a string value.
-
setValidator
public void setValidator(WValidator validator)
Sets a validator for this field.The validator is used to validate the current input.
The default value is
null.- See Also:
validate()
-
getValidator
public WValidator getValidator()
Returns the validator.
-
validate
public ValidationState validate()
Validates the field.- See Also:
validated()
-
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:
setEnabled(boolean enabled)
-
isReadOnly
public boolean isReadOnly()
Returns whether the form element is read-only.- See Also:
setReadOnly(boolean readOnly)
-
setPlaceholderText
public void setPlaceholderText(java.lang.CharSequence placeholderText)
Sets the placeholder text.This sets the text that is shown when the field is empty.
-
getPlaceholderText
public WString getPlaceholderText()
Returns the placeholder text.
-
changed
public EventSignal changed()
Signal emitted when the value was changed.For a keyboard input, the signal is only emitted when the focus is lost
-
validated
public Signal1<WValidator.Result> validated()
Signal emitted when the widget is being validated.This signal may be useful to react to a changed validation state.
- See Also:
validate()
-
refresh
public void refresh()
Description copied from class:WWidgetRefresh 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:
refreshin classWWebWidget
-
setToolTip
public void setToolTip(java.lang.CharSequence text, TextFormat textFormat)Description copied from class:WWidgetSets a tooltip.The tooltip is displayed when the cursor hovers over the widget.
When
textFormatisTextFormat.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:
setToolTipin classWWebWidget
-
isCanReceiveFocus
public boolean isCanReceiveFocus()
Description copied from class:WWidgetReturns whether the widget can receive focus.- Overrides:
isCanReceiveFocusin classWWebWidget- See Also:
WWidget.setCanReceiveFocus(boolean enabled)
-
getTabIndex
public int getTabIndex()
Description copied from class:WWidgetReturns the tab index.- Overrides:
getTabIndexin classWWebWidget- See Also:
WWidget.setTabIndex(int index)
-
enableAjax
protected void enableAjax()
Description copied from class:WWidgetProgresses 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:
enableAjaxin classWWebWidget- See Also:
WApplication.enableAjax()
-
validatorChanged
protected void validatorChanged()
-
hasValidatorChanged
protected boolean hasValidatorChanged()
-
getRealValidator
protected WValidator getRealValidator()
-
render
protected void render(java.util.EnumSet<RenderFlag> flags)
Description copied from class:WWidgetRenders 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:
renderin classWInteractWidget
-
propagateSetEnabled
protected void propagateSetEnabled(boolean enabled)
Description copied from class:WWidgetPropagates 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:
propagateSetEnabledin classWInteractWidget
-
-