Package org.opencms.gwt.client.ui.input
Class CmsTextBox
java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.Composite
org.opencms.gwt.client.ui.input.CmsTextBox
- All Implemented Interfaces:
com.google.gwt.event.dom.client.HasBlurHandlers,com.google.gwt.event.dom.client.HasClickHandlers,com.google.gwt.event.dom.client.HasFocusHandlers,com.google.gwt.event.dom.client.HasKeyPressHandlers,com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.IsRenderable,com.google.gwt.user.client.ui.IsWidget,I_CmsHasInit,I_CmsFormWidget,I_CmsHasBlur,I_CmsHasGhostValue
- Direct Known Subclasses:
CmsFocusAwareTextBox
public class CmsTextBox
extends com.google.gwt.user.client.ui.Composite
implements I_CmsFormWidget, I_CmsHasInit, com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.dom.client.HasBlurHandlers, com.google.gwt.event.logical.shared.HasValueChangeHandlers<String>, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.HasClickHandlers, I_CmsHasBlur, I_CmsHasGhostValue
Basic text box class for forms.
- Since:
- 8.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabledNested classes/interfaces inherited from interface org.opencms.gwt.client.ui.input.I_CmsFormWidget
I_CmsFormWidget.FieldType -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final I_CmsInputCssThe CSS bundle used for this widget.protected StringThe ghost value.protected com.google.gwt.user.client.ui.TextBoxThe text box used internally by this widget.protected static final int[]Key codes for functional keys.static final StringThe widget type identifier for this widget.Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance of this widget.CmsTextBox(com.google.gwt.user.client.ui.TextBox textbox) Creates a new text box based on an underlying GWT text box instance. -
Method Summary
Modifier and TypeMethodDescriptioncom.google.gwt.event.shared.HandlerRegistrationaddBlurHandler(com.google.gwt.event.dom.client.BlurHandler handler) com.google.gwt.event.shared.HandlerRegistrationaddClickHandler(com.google.gwt.event.dom.client.ClickHandler handler) com.google.gwt.event.shared.HandlerRegistrationaddFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler) com.google.gwt.event.shared.HandlerRegistrationaddKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler) com.google.gwt.event.shared.HandlerRegistrationaddKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler) Adds a handler for the keyup event.com.google.gwt.event.shared.HandlerRegistrationaddValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<String> handler) voidblur()Makes the widget lose focus.Sets the background color to white.protected voidFires a value change event.protected voidfireValueChangedEvent(boolean inhibitValidation) Helper method for firing a 'value changed' event.Returns the "apparent value", i.e.Returns the type of data this widget produces.Gets the selected/entered value from the widget.Gets the current value of the widget as a string.getId()Returns the HTML id of the internal textbox used by this widget.getText()Returns the text in the text box.com.google.gwt.user.client.ui.TextBoxReturns the Textbox of this widget.com.google.gwt.user.client.ui.FlowPanelReturns the Panel of this widget.booleanhasError()Returnstrueif this textbox has an error set.protected voidHides the error for this textbox.static voidInitializes this class.booleanGets whether this widget is enabled.protected booleanisNavigationKey(int keyCode) Checks if the given key code represents a functional key.booleanReturns the preventShowError.booleanReturns the read only flag.booleanReturns if the text box is set to trigger the value changed event on key press and not on blur only.voidonBrowserEvent(com.google.gwt.user.client.Event event) voidreset()Resets the widget to its default state.voidSelects text in the text box.voidsetAutoHideParent(I_CmsAutoHider autoHideParent) Call this when auto hiding parents are shown.voidSets the changed style on the text box.voidsetEnabled(boolean enabled) Enables or disables the widget.voidsetErrorMessage(String errorMessage) Sets the error message for this widget.voidsetErrorMessageWidth(String width) Sets the width of the error message for this textbox.voidsetFocus(boolean focused) Sets the focus on the text box.voidsetFormValueAsString(String newValue) Sets the current value of the widget as a string.voidsetGhostMode(boolean ghostMode) Enables or disables ghost mode.voidsetGhostModeClear(boolean clearOnChangeMode) Sets if the input field should be cleared when leaving the ghost mode.voidsetGhostStyleEnabled(boolean enabled) Enables or disables the "ghost mode" style.voidsetGhostValue(String value, boolean ghostMode) Sets the "ghost value" of the widget and optionally sets it to "ghost mode".voidsetInhibitValidationForKeypresses(boolean inhibitValidationForKeypresses) Sets the 'inhibitValidationForKeypresses' flag.voidSets the name of the input box.voidsetPreventShowError(boolean preventShowError) Sets the preventShowError.voidsetReadOnly(boolean readOnly) Enables or disables read-only mode.voidsetTriggerChangeOnKeyPress(boolean triggerOnKeyPress) Sets if the value changed event should be triggered on key press and not on blur only.protected voidShows the error for this textbox.Methods inherited from class com.google.gwt.user.client.ui.Composite
claimElement, getWidget, initializeClaimedElement, initWidget, isAttached, onAttach, onDetach, render, render, resolvePotentialElement, setWidgetMethods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEventsMethods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Field Details
-
CSS
The CSS bundle used for this widget. -
WIDGET_TYPE
The widget type identifier for this widget.- See Also:
-
NAVIGATION_CODES
Key codes for functional keys. -
m_ghostValue
The ghost value. -
m_textbox
The text box used internally by this widget.
-
-
Constructor Details
-
CmsTextBox
public CmsTextBox()Constructs a new instance of this widget. -
CmsTextBox
Creates a new text box based on an underlying GWT text box instance.- Parameters:
textbox- the GWT text box instance to wrap
-
-
Method Details
-
initClass
Initializes this class. -
addBlurHandler
public com.google.gwt.event.shared.HandlerRegistration addBlurHandler(com.google.gwt.event.dom.client.BlurHandler handler) - Specified by:
addBlurHandlerin interfacecom.google.gwt.event.dom.client.HasBlurHandlers- See Also:
-
addClickHandler
public com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler) - Specified by:
addClickHandlerin interfacecom.google.gwt.event.dom.client.HasClickHandlers- See Also:
-
addFocusHandler
public com.google.gwt.event.shared.HandlerRegistration addFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler) - Specified by:
addFocusHandlerin interfacecom.google.gwt.event.dom.client.HasFocusHandlers- See Also:
-
addKeyPressHandler
public com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler) - Specified by:
addKeyPressHandlerin interfacecom.google.gwt.event.dom.client.HasKeyPressHandlers- See Also:
-
addKeyUpHandler
public com.google.gwt.event.shared.HandlerRegistration addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler) Adds a handler for the keyup event.- Parameters:
handler- the handler- Returns:
- the handler registration
-
blur
Description copied from interface:I_CmsHasBlurMakes the widget lose focus.- Specified by:
blurin interfaceI_CmsHasBlur- See Also:
-
colorWhite
Sets the background color to white.- Returns:
- this widget
-
getApparentValue
Description copied from interface:I_CmsFormWidgetReturns the "apparent value", i.e. either the real value if available, or else the ghost value if available, or null otherwise.- Specified by:
getApparentValuein interfaceI_CmsFormWidget- Returns:
- the apparent value
- See Also:
-
getFieldType
Description copied from interface:I_CmsFormWidgetReturns the type of data this widget produces.- Specified by:
getFieldTypein interfaceI_CmsFormWidget- Returns:
- the data type
- See Also:
-
getFormValue
Description copied from interface:I_CmsFormWidgetGets the selected/entered value from the widget.- Specified by:
getFormValuein interfaceI_CmsFormWidget- Returns:
- the value
- See Also:
-
getFormValueAsString
Description copied from interface:I_CmsFormWidgetGets the current value of the widget as a string.- Specified by:
getFormValueAsStringin interfaceI_CmsFormWidget- Returns:
- the current value of the widget
- See Also:
-
getId
Returns the HTML id of the internal textbox used by this widget.- Returns:
- the HTML id of the internal textbox used by this widget
-
getText
Returns the text in the text box.- Returns:
- the text
-
getTextBox
Returns the Textbox of this widget.- Returns:
- the CmsTextBox
-
getTextBoxContainer
Returns the Panel of this widget.- Returns:
- the Panel
-
hasError
Returnstrueif this textbox has an error set.- Returns:
trueif this textbox has an error set
-
isEnabled
Gets whether this widget is enabled.- Specified by:
isEnabledin interfaceI_CmsFormWidget- Returns:
trueif the widget is enabled
-
isPreventShowError
Returns the preventShowError.- Returns:
- the preventShowError
-
isReadOnly
Returns the read only flag.- Returns:
trueif this text box is only readable
-
isTriggerChangeOnKeyPress
Returns if the text box is set to trigger the value changed event on key press and not on blur only.- Returns:
trueif the text box is set to trigger the value changed event on key press
-
onBrowserEvent
- Specified by:
onBrowserEventin interfacecom.google.gwt.user.client.EventListener- Overrides:
onBrowserEventin classcom.google.gwt.user.client.ui.Composite- See Also:
-
reset
Description copied from interface:I_CmsFormWidgetResets the widget to its default state.- Specified by:
resetin interfaceI_CmsFormWidget- See Also:
-
selectAll
Selects text in the text box. -
setAutoHideParent
Description copied from interface:I_CmsFormWidgetCall this when auto hiding parents are shown.- Specified by:
setAutoHideParentin interfaceI_CmsFormWidget- Parameters:
autoHideParent- the auto hide parent- See Also:
-
setChangedStyle
Sets the changed style on the text box. -
setEnabled
Description copied from interface:I_CmsFormWidgetEnables or disables the widget.- Specified by:
setEnabledin interfaceI_CmsFormWidget- Parameters:
enabled- if true, the widget will be enabled, else disabled- See Also:
-
setErrorMessage
Description copied from interface:I_CmsFormWidgetSets the error message for this widget.If the error message is null, no error message will be displayed.
- Specified by:
setErrorMessagein interfaceI_CmsFormWidget- Parameters:
errorMessage- an error message or null- See Also:
-
setErrorMessageWidth
Sets the width of the error message for this textbox.- Parameters:
width- the object's new width, in CSS units (e.g. "10px", "1em")
-
setFocus
Sets the focus on the text box.- Parameters:
focused- signals if the focus should be set
-
setFormValueAsString
Description copied from interface:I_CmsFormWidgetSets the current value of the widget as a string.- Specified by:
setFormValueAsStringin interfaceI_CmsFormWidget- Parameters:
newValue- the new value of the widget- See Also:
-
setGhostMode
Enables or disables ghost mode.- Specified by:
setGhostModein interfaceI_CmsHasGhostValue- Parameters:
ghostMode- if true, enables ghost mode, else disables it
-
setGhostModeClear
Sets if the input field should be cleared when leaving the ghost mode.- Parameters:
clearOnChangeMode-trueto clear on leaving the ghost mode
-
setGhostStyleEnabled
Enables or disables the "ghost mode" style.This *only* changes the style, not the actual mode.
- Parameters:
enabled-trueif the ghost mode style should be enabled, false if it should be disabled
-
setGhostValue
Description copied from interface:I_CmsHasGhostValueSets the "ghost value" of the widget and optionally sets it to "ghost mode"."Ghost mode" can be used to show the user the value (called "ghost value") which will be used if he either doesn't choose an option in the widget, or explicitly chooses an "empty" or "default" option.
- Specified by:
setGhostValuein interfaceI_CmsHasGhostValue- Parameters:
value- the ghost valueghostMode- if true, sets the widget to ghost mode- See Also:
-
setInhibitValidationForKeypresses
Sets the 'inhibitValidationForKeypresses' flag.- Parameters:
inhibitValidationForKeypresses- the new flag value
-
setName
Sets the name of the input box.- Parameters:
name- of the input box
-
setPreventShowError
Sets the preventShowError.- Parameters:
preventShowError- the preventShowError to set
-
setReadOnly
Enables or disables read-only mode.- Parameters:
readOnly- if true, enables read-only mode, else disables it
-
setTriggerChangeOnKeyPress
Sets if the value changed event should be triggered on key press and not on blur only.- Parameters:
triggerOnKeyPress-trueif the value changed event should be triggered on key press
-
fireValueChangedEvent
Fires a value change event. -
fireValueChangedEvent
Helper method for firing a 'value changed' event.- Parameters:
inhibitValidation- if true, some additional information will be added to the event to ask event handlers to not perform any validation directly
-
hideError
Hides the error for this textbox. -
showError
Shows the error for this textbox.
-