Class 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:

    1. value: The value of this form item which has the type T
    2. expression value: The expression value of this form item (if expressions are supported). The expression value is always a string.
    3. 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 Detail

      • attach

        public void attach()
        Calls SuggestHandler.attach() in case there was one registered. If you override this method, please call super.attach() to keep this behaviour.
        Specified by:
        attach in interface Attachable
      • getValue

        public T getValue()
        Specified by:
        getValue in interface com.google.gwt.user.client.ui.HasValue<T>
        Specified by:
        getValue in interface com.google.gwt.user.client.TakesValue<T>
      • setValue

        public void setValue​(T value)
        Specified by:
        setValue in interface com.google.gwt.user.client.ui.HasValue<T>
        Specified by:
        setValue in interface com.google.gwt.user.client.TakesValue<T>
      • 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 to null. Does not touch the modified and undefined flags. Should be called from business code like form mapping.
        Specified by:
        setValue in interface com.google.gwt.user.client.ui.HasValue<T>
      • clearValue

        public void clearValue()
        Sets the value and expression value to null, clears any error marker and shows the default value (if any). Does not touch the modified and undefined flags. Should be called from business code like form mapping.
        Specified by:
        clearValue in interface FormItem<T>
      • assignDefaultValue

        public void assignDefaultValue​(T defaultValue)
        Stores the default value for later use. The default value will be used in setValue(Object) (if the value is null or empty) and clearValue(). Calling this method will not immediately show the default value.
        Specified by:
        assignDefaultValue in interface FormItem<T>
      • mask

        public void mask()
        Specified by:
        mask in interface FormItem<T>
      • unmask

        public void unmask()
        Specified by:
        unmask in interface FormItem<T>
      • fireEvent

        public void fireEvent​(com.google.gwt.event.shared.GwtEvent<?> gwtEvent)
        Specified by:
        fireEvent in interface com.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:
        addValueChangeHandler in interface com.google.gwt.event.logical.shared.HasValueChangeHandlers<T>
      • getName

        public String getName()
        Specified by:
        getName in interface com.google.gwt.user.client.ui.HasName
      • setName

        public void setName​(String name)
        Specified by:
        setName in interface com.google.gwt.user.client.ui.HasName
      • validate

        public boolean validate()
        Specified by:
        validate in interface FormItem<T>
      • clearError

        public void clearError()
        Clears any error markers. This method unapplies the INVALID decoration.
        Specified by:
        clearError in interface FormItem<T>
      • showError

        public void showError​(String message)
        Shows the specified error message. This method applies the INVALID decoration using the error message as context.
        Specified by:
        showError in interface FormItem<T>
      • setExpressionAllowed

        public void setExpressionAllowed​(boolean expressionAllowed)
        Specified by:
        setExpressionAllowed in interface FormItem<T>
      • setExpressionValue

        public void setExpressionValue​(String expressionValue)
        Sets the form item's expression value, applies the Decoration.EXPRESSION decoration and shows the expression value in the appearances. Sets the value to null. Does not touch the modified and undefined flags. Should be called from business code like form mapping.
        Specified by:
        setExpressionValue in interface FormItem<T>
      • onSuggest

        public void onSuggest​(String suggestion)
      • setRestricted

        public void setRestricted​(boolean restricted)
        Specified by:
        setRestricted in interface FormItem<T>
      • isEnabled

        public boolean isEnabled()
        Specified by:
        isEnabled in interface com.google.gwt.user.client.ui.HasEnabled
      • setEnabled

        public void setEnabled​(boolean enabled)
        Specified by:
        setEnabled in interface com.google.gwt.user.client.ui.HasEnabled
      • getTabIndex

        public int getTabIndex()
        Specified by:
        getTabIndex in interface com.google.gwt.user.client.ui.Focusable
      • setTabIndex

        public void setTabIndex​(int index)
        Specified by:
        setTabIndex in interface com.google.gwt.user.client.ui.Focusable
      • setAccessKey

        public void setAccessKey​(char accessKey)
        Specified by:
        setAccessKey in interface com.google.gwt.user.client.ui.Focusable
      • setFocus

        public void setFocus​(boolean focus)
        Specified by:
        setFocus in interface com.google.gwt.user.client.ui.Focusable
      • setRequired

        public void setRequired​(boolean required)
        Specified by:
        setRequired in interface FormItem<T>
      • isModified

        public final boolean isModified()
        Specified by:
        isModified in interface FormItem<T>
      • setModified

        public void setModified​(boolean modified)
        Specified by:
        setModified in interface FormItem<T>
      • isUndefined

        public final boolean isUndefined()
        Specified by:
        isUndefined in interface FormItem<T>
      • setUndefined

        public void setUndefined​(boolean undefined)
        Specified by:
        setUndefined in interface FormItem<T>
      • setDeprecated

        public void setDeprecated​(org.jboss.hal.dmr.Deprecation deprecation)
        Specified by:
        setDeprecated in interface FormItem<T>