Package org.jboss.hal.ballroom.form
Class AbstractFormItem<T>
- java.lang.Object
-
- org.jboss.hal.ballroom.form.AbstractFormItem<T>
-
- Type Parameters:
T- The type of the form item's value.
- All Implemented Interfaces:
com.google.gwt.event.logical.shared.HasValueChangeHandlers<T>,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.TakesValue<T>,com.google.gwt.user.client.ui.Focusable,com.google.gwt.user.client.ui.HasEnabled,com.google.gwt.user.client.ui.HasName,com.google.gwt.user.client.ui.HasValue<T>,Attachable,FormItem<T>
- Direct Known Subclasses:
ButtonItem,CompositeFormItem,FileItem,MultiSelectBoxItem,NumberDoubleItem,NumberItem,NumberSelectItem,RadioItem,SingleSelectBoxItem,StaticItem,SwitchItem,TagsItem,TextBoxItem
public abstract class AbstractFormItem<T> extends Object implements FormItem<T>
Base class for all form item implementations. Contains central logic for handling (default) values, various flags, validation, expressions and event handling. All UI and DOM related code can be found in appearances.A form item carries three different values:
- value: The value of this form item which has the type
T - expression value: The expression value of this form item (if expressions are supported). The expression value is always a string.
- default value: The default value of this form item (if any) which has the type
T
The value and the expression value are mutual exclusive. Only one of them is allowed to be non-null.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEncryptExpressionHandler(EncryptExpressionEvent.EncryptExpressionHandler handler)voidaddResolveExpressionHandler(ResolveExpressionEvent.ResolveExpressionHandler handler)voidaddValidationHandler(FormItemValidation<T> validationHandler)com.google.gwt.event.shared.HandlerRegistrationaddValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<T> valueChangeHandler)voidassignDefaultValue(T defaultValue)Stores the default value for later use.voidattach()CallsSuggestHandler.attach()in case there was one registered.voidclearError()Clears any error markers.voidclearValue()Sets the value and expression value tonull, clears any error marker and shows the default value (if any).voiddetach()elemental2.dom.HTMLElementelement(Form.State state)voidfireEvent(com.google.gwt.event.shared.GwtEvent<?> gwtEvent)StringgetExpressionValue()StringgetId(Form.State state)StringgetLabel()StringgetName()intgetTabIndex()TgetValue()booleanisDeprecated()booleanisEnabled()booleanisExpressionAllowed()booleanisExpressionValue()booleanisModified()booleanisRequired()booleanisRestricted()booleanisUndefined()voidmask()voidonSuggest(String suggestion)voidregisterSuggestHandler(SuggestHandler suggestHandler)voidsetAccessKey(char accessKey)voidsetDeprecated(org.jboss.hal.dmr.Deprecation deprecation)voidsetEnabled(boolean enabled)voidsetExpressionAllowed(boolean expressionAllowed)voidsetExpressionValue(String expressionValue)Sets the form item's expression value, applies theDecoration.EXPRESSIONdecoration and shows the expression value in the appearances.voidsetFocus(boolean focus)voidsetId(String id)voidsetLabel(String label)voidsetModified(boolean modified)voidsetName(String name)voidsetRequired(boolean required)voidsetRestricted(boolean restricted)voidsetTabIndex(int index)voidsetUndefined(boolean undefined)voidsetValue(T value)voidsetValue(T value, boolean fireEvent)Sets the form item's value and shows the value in the appearances.voidshowError(String message)Shows the specified error message.voidunmask()booleanvalidate()-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.hal.ballroom.form.FormItem
isEmpty, supportsExpressions
-
-
-
-
Method Detail
-
element
public elemental2.dom.HTMLElement element(Form.State state)
-
attach
public void attach()
CallsSuggestHandler.attach()in case there was one registered. If you override this method, please callsuper.attach()to keep this behaviour.- Specified by:
attachin interfaceAttachable
-
detach
public void detach()
- Specified by:
detachin interfaceAttachable
-
getId
public String getId(Form.State state)
-
getValue
public T getValue()
-
setValue
public void setValue(T value)
-
setValue
public void setValue(T value, boolean fireEvent)
Sets the form item's value and shows the value in the appearances. Sets the expression value tonull. Does not touch themodifiedandundefinedflags. Should be called from business code like form mapping.- Specified by:
setValuein interfacecom.google.gwt.user.client.ui.HasValue<T>
-
clearValue
public void clearValue()
Sets the value and expression value tonull, clears any error marker and shows the default value (if any). Does not touch themodifiedandundefinedflags. Should be called from business code like form mapping.- Specified by:
clearValuein interfaceFormItem<T>
-
assignDefaultValue
public void assignDefaultValue(T defaultValue)
Stores the default value for later use. The default value will be used insetValue(Object)(if the value is null or empty) andclearValue(). Calling this method will not immediately show the default value.- Specified by:
assignDefaultValuein interfaceFormItem<T>
-
fireEvent
public void fireEvent(com.google.gwt.event.shared.GwtEvent<?> gwtEvent)
- Specified by:
fireEventin interfacecom.google.gwt.event.shared.HasHandlers
-
addValueChangeHandler
public com.google.gwt.event.shared.HandlerRegistration addValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler<T> valueChangeHandler)
- Specified by:
addValueChangeHandlerin interfacecom.google.gwt.event.logical.shared.HasValueChangeHandlers<T>
-
getName
public String getName()
- Specified by:
getNamein interfacecom.google.gwt.user.client.ui.HasName
-
setName
public void setName(String name)
- Specified by:
setNamein interfacecom.google.gwt.user.client.ui.HasName
-
addValidationHandler
public void addValidationHandler(FormItemValidation<T> validationHandler)
- Specified by:
addValidationHandlerin interfaceFormItem<T>
-
clearError
public void clearError()
Clears any error markers. This method unapplies the INVALID decoration.- Specified by:
clearErrorin interfaceFormItem<T>
-
showError
public void showError(String message)
Shows the specified error message. This method applies the INVALID decoration using the error message as context.
-
isExpressionAllowed
public boolean isExpressionAllowed()
- Specified by:
isExpressionAllowedin interfaceFormItem<T>
-
setExpressionAllowed
public void setExpressionAllowed(boolean expressionAllowed)
- Specified by:
setExpressionAllowedin interfaceFormItem<T>
-
isExpressionValue
public boolean isExpressionValue()
- Specified by:
isExpressionValuein interfaceFormItem<T>
-
getExpressionValue
public String getExpressionValue()
- Specified by:
getExpressionValuein interfaceFormItem<T>
-
setExpressionValue
public void setExpressionValue(String expressionValue)
Sets the form item's expression value, applies theDecoration.EXPRESSIONdecoration and shows the expression value in the appearances. Sets the value tonull. Does not touch themodifiedandundefinedflags. Should be called from business code like form mapping.- Specified by:
setExpressionValuein interfaceFormItem<T>
-
addResolveExpressionHandler
public void addResolveExpressionHandler(ResolveExpressionEvent.ResolveExpressionHandler handler)
- Specified by:
addResolveExpressionHandlerin interfaceFormItem<T>
-
addEncryptExpressionHandler
public void addEncryptExpressionHandler(EncryptExpressionEvent.EncryptExpressionHandler handler)
- Specified by:
addEncryptExpressionHandlerin interfaceFormItem<T>
-
registerSuggestHandler
public void registerSuggestHandler(SuggestHandler suggestHandler)
- Specified by:
registerSuggestHandlerin interfaceFormItem<T>
-
onSuggest
public void onSuggest(String suggestion)
-
isRestricted
public boolean isRestricted()
- Specified by:
isRestrictedin interfaceFormItem<T>
-
setRestricted
public void setRestricted(boolean restricted)
- Specified by:
setRestrictedin interfaceFormItem<T>
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfacecom.google.gwt.user.client.ui.HasEnabled
-
setEnabled
public void setEnabled(boolean enabled)
- Specified by:
setEnabledin interfacecom.google.gwt.user.client.ui.HasEnabled
-
getTabIndex
public int getTabIndex()
- Specified by:
getTabIndexin interfacecom.google.gwt.user.client.ui.Focusable
-
setTabIndex
public void setTabIndex(int index)
- Specified by:
setTabIndexin interfacecom.google.gwt.user.client.ui.Focusable
-
setAccessKey
public void setAccessKey(char accessKey)
- Specified by:
setAccessKeyin interfacecom.google.gwt.user.client.ui.Focusable
-
setFocus
public void setFocus(boolean focus)
- Specified by:
setFocusin interfacecom.google.gwt.user.client.ui.Focusable
-
isRequired
public boolean isRequired()
- Specified by:
isRequiredin interfaceFormItem<T>
-
setRequired
public void setRequired(boolean required)
- Specified by:
setRequiredin interfaceFormItem<T>
-
isModified
public final boolean isModified()
- Specified by:
isModifiedin interfaceFormItem<T>
-
setModified
public void setModified(boolean modified)
- Specified by:
setModifiedin interfaceFormItem<T>
-
isUndefined
public final boolean isUndefined()
- Specified by:
isUndefinedin interfaceFormItem<T>
-
setUndefined
public void setUndefined(boolean undefined)
- Specified by:
setUndefinedin interfaceFormItem<T>
-
isDeprecated
public boolean isDeprecated()
- Specified by:
isDeprecatedin interfaceFormItem<T>
-
setDeprecated
public void setDeprecated(org.jboss.hal.dmr.Deprecation deprecation)
- Specified by:
setDeprecatedin interfaceFormItem<T>
-
-