VALUE - is the generic type of the value.ADAPTER - is the generic type of AbstractUiWidgetNative.getWidgetAdapter().public abstract class AbstractUiWidgetOptionsField<ADAPTER extends UiWidgetAdapterOptionsField<VALUE>,VALUE> extends AbstractUiWidgetField<ADAPTER,VALUE,String> implements UiWidgetOptionsField<VALUE>, AttributeWriteAllowCustomInput
UiWidgetOptionsField.AbstractUiWidgetNative.SizeImplAbstractUiWidget.AccessHelper, AbstractUiWidget.EventSender, AbstractUiWidget.HandlerContainer| Modifier and Type | Field and Description |
|---|---|
private boolean |
allowCustomInput |
static String |
CODE_UNDEFINED_OPTION
The
validation failure code for an
undefined option. |
private Formatter<VALUE> |
formatter |
private List<VALUE> |
mutableOptions |
private String |
nullValue |
private List<VALUE> |
options |
private List<String> |
optionTitleList |
private Map<String,VALUE> |
title2OptionMap
Maps the
formatted title back to the original value. |
STYLE_FIELD, STYLE_LABEL, STYLE_MANDATORY, STYLE_VIEWSTYLE_HEADERHTML_ATTRIBUTE_ID, ID_SEPARATOR, PROPERTY_IDPROPERTY_STYLES, STYLE_PATTERN_MULTIPLE, STYLE_PATTERN_SINGLEWAI_ARIAPROPERTY_LABELACCESS_KEY_NONE, HTML_ATTRIBUTE_ACCESS_KEY| Constructor and Description |
|---|
AbstractUiWidgetOptionsField(UiContext context,
ADAPTER widgetAdapter)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected VALUE |
convertCustomInputToValue(String customInput)
Converts the given
customInput to <VALUE>. |
protected String |
convertFromValue(VALUE widgetValue)
This method converts the given
widgetValue to the type used by the
widget adapter. |
protected VALUE |
convertToValue(String adapterValue,
ValidationState state)
|
protected String |
convertValueToString(VALUE option)
Converts the given value to
String. |
protected VALUE |
doGetValue(VALUE template,
ValidationState state)
This method is called from the
data-binding triggered by API methods such as
AbstractUiFeatureValueAndValidation.getValue(). |
Formatter<VALUE> |
getFormatter()
This method gets the
Formatter of this object. |
protected String |
getNullValue()
This method gets the result of
AbstractUiWidgetField.convertFromValue(Object) for the value null. |
List<VALUE> |
getOptions()
This method gets the options of this object.
|
protected Class<VALUE> |
getValueClass() |
protected void |
initializeWidgetAdapter(ADAPTER adapter)
This method is called from
AbstractUiWidgetNative.getWidgetAdapter() to initialize the UiWidgetAdapter. |
boolean |
isAllowCustomInput()
This method determines if custom input is allowed by this object (widget).
|
void |
setAllowCustomInput(boolean allowCustomInput)
This method sets the
allowCustomInput flag. |
void |
setFormatter(Formatter<VALUE> formatter)
This method sets the
formatter of this object. |
void |
setOptions(List<VALUE> options)
This method sets the
options of this object. |
clearValidationFailure, doSetValue, getLabel, getLabelWidget, getSource, getValidationFailure, getValueAsString, getValueDirect, isTrimValue, setId, setLabel, setMandatory, setTrimValue, setValidationFailure, setValue, setValueAsString, setVisible, toStringaddFocusHandler, getAccessKey, isFocused, onAccessKeyPressed, removeFocusHandler, setAccessKey, setFocused, setFocusedaddChangeHandler, addStyle, clearMessages, clearValidity, createSize, createUniqueId, createWidgetAdapter, dispose, doSetMode, doValidate, getAriaRole, getAriaRoleFixedType, getChild, getChild, getChildCount, getChildIndex, getId, getIndexOfStyle, getMode, getModeFixed, getParent, getPrimaryStyle, getSize, getStyles, getTooltip, getVisibleFlag, getWidgetAdapter, getWidgetAdapter, hasStyle, hasWidgetAdapter, isDisposed, isEnabled, isModifiedRecursive, isVisible, isVisibleRecursive, removeChangeHandler, removeFromParent, removeStyle, setAriaRole, setEnabled, setIdPrefix, setMode, setMode, setModeFixed, setParent, setPrimaryStyle, setStyles, setTooltip, setVisible, visibilityChangedaddEventHandler, addValidator, clearMessagesLocal, fireEvent, fireValueChange, getBasicUtil, getContext, getDataBinding, getDataBinding, getDataBindingForWidget, getEventSender, getFactory, getLogger, getObserverSource, getOriginalValue, getRecentValue, getValueOrException, getWidgetAdapter, hasEventSender, isMandatory, isModified, removeEventHandler, removeFromParent, removeValidator, setModified, setParentaddValidatorMandatory, createValidationFailure, getValue, getValueAndValidate, handleGetValueError, resetValue, setValue, setValueForUser, validateclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetLabel, getLabelWidget, setLabelgetChild, getChildgetChildCount, getChildIndexgetContext, getParent, getSizeclearMessagesaddEventHandler, removeEventHandlersetModegetModesetModeFixedgetModeFixedsetIdgetIdsetTooltipgetTooltipgetVisibleFlag, isVisible, setVisible, setVisibleisVisibleRecursivesetEnabledisEnabledaddStyle, removeStylehasStylesetStylesgetStylessetPrimaryStylegetPrimaryStyledisposeisDisposedisModifiedgetAriaRolegetValuegetValueAndValidate, getValueDirectaddChangeHandler, removeChangeHandlerresetValue, setValue, setValue, setValueForUsergetOriginalValue, getValueOrExceptionaddValidatorMandatory, isMandatoryaddValidator, removeValidatorsetValueAsStringgetValueAsStringsetValidationFailuregetValidationFailuresetTrimValueisTrimValuesetAccessKeygetAccessKeyaddFocusHandler, removeFocusHandlerisFocusedsetFocusedpublic static final String CODE_UNDEFINED_OPTION
validation failure code for an
undefined option.private final List<VALUE> mutableOptions
getOptions()private final List<VALUE> options
getOptions()private List<String> optionTitleList
setOptions(List)private final Map<String,VALUE> title2OptionMap
formatted title back to the original value.private Formatter<VALUE> formatter
getFormatter()private String nullValue
getNullValue()private boolean allowCustomInput
isAllowCustomInput()public AbstractUiWidgetOptionsField(UiContext context, ADAPTER widgetAdapter)
context - is the context.widgetAdapter - is the widget adapter. Typically null for
lazy initialization.protected Class<VALUE> getValueClass()
getValueClass in class AbstractUiWidgetField<ADAPTER extends UiWidgetAdapterOptionsField<VALUE>,VALUE,String>Class reflecting <VALUE>. May also be null for Void.protected void initializeWidgetAdapter(ADAPTER adapter)
AbstractUiWidgetNative.getWidgetAdapter() to initialize the UiWidgetAdapter. All
attributes of this widget need to be set in the UiWidgetAdapter.initializeWidgetAdapter in class AbstractUiWidgetField<ADAPTER extends UiWidgetAdapterOptionsField<VALUE>,VALUE,String>adapter - is the UiWidgetAdapter to initialize.public void setOptions(List<VALUE> options)
options of this object. The options will be presented in their
order specified by the given List.setOptions in interface AttributeWriteOptions<VALUE>options - is the new List of available options.protected String convertValueToString(VALUE option)
String.convertValueToString in class AbstractUiWidget<VALUE>option - is the value to convert.String representation to display the given value.protected VALUE doGetValue(VALUE template, ValidationState state) throws RuntimeException
data-binding triggered by API methods such as
AbstractUiFeatureValueAndValidation.getValue(). In many cases the data-binding already performs the
required work to do. However, here is the place to implemented the custom logic to get the value from the
actual widget. The following cases have to be distinguished:
native
fields this method has to get the actual
value from the underlying native widget (text-box, password-field, etc.).custom fields this
method will be responsible to convert from the delegates value (see
UiWidgetCustom.getDelegate()) to the proper value type. E.g. if you want to create a custom
widget to edit your own datatype such as CustomerNumber based on a
UiWidgetTextField you need to convert from String
to CustomerNumber.custom composite widgets
you should use AbstractUiWidget.getDataBinding().
UiDataBinding.createAndBind(net.sf.mmm.util.pojo.path.api.TypedProperty)
that gives you high-level support and makes your live easy. Then there is no need to override this
method.Void, there is nothing to do here.AbstractUiWidget.doSetValue(Object, boolean) .doGetValue in class AbstractUiWidgetField<ADAPTER extends UiWidgetAdapterOptionsField<VALUE>,VALUE,String>template - is the object where the data is filled in. May only be null if according to
data-binding (e.g. if <VALUE> is an (immutable)
Datatype).state - is the ValidationState. May be null (if the validation is omitted).
Should only be used to propagate to AbstractUiWidget.getValueDirect(Object, ValidationState) of children.null if empty. If <VALUE> is
String the empty String has to be returned if no value has been entered. In case
<VALUE> is a mutable object (java bean) the template is NOT
null and is to be returned by this method after the value(s) of this widget have
been assigned. For immutable datatypes
template will be null and this method has to create a new instance of
<VALUE> based on the end-users input in the widget.RuntimeExceptionAbstractUiWidget.doSetValue(Object, boolean)protected String convertFromValue(VALUE widgetValue)
widgetValue to the type used by the
widget adapter. The default implementation simply performs a cast. You have
to override this method if <VALUE> and <WIDGET_VALUE> differ.convertFromValue in class AbstractUiWidgetField<ADAPTER extends UiWidgetAdapterOptionsField<VALUE>,VALUE,String>widgetValue - is the value to convert. Will NOT be null (See AbstractUiWidgetField.getNullValue()).protected VALUE convertToValue(String adapterValue, ValidationState state)
adapterValue from the widget
adapter to the type of this value. The default implementation simply performs a
cast. You have to override this method if <VALUE> and <WIDGET_VALUE> differ.convertToValue in class AbstractUiWidgetField<ADAPTER extends UiWidgetAdapterOptionsField<VALUE>,VALUE,String>adapterValue - is the value to convert. Will NOT be null.state - is the ValidationState or null if not called without validation.protected VALUE convertCustomInputToValue(String customInput)
customInput to <VALUE>.customInput - is the custom input.isAllowCustomInput()protected String getNullValue()
AbstractUiWidgetField.convertFromValue(Object) for the value null. It is
called for null values instead of AbstractUiWidgetField.convertFromValue(Object) to prevent
NullPointerExceptions. The default is null - override to change.getNullValue in class AbstractUiWidgetField<ADAPTER extends UiWidgetAdapterOptionsField<VALUE>,VALUE,String>null for the widget adapter.public List<VALUE> getOptions()
List shall not contain duplicate entries. It may contain the value
null.getOptions in interface AttributeReadOptions<VALUE>List with all available options.public void setFormatter(Formatter<VALUE> formatter)
formatter of this object. i18n when implementing formatters.
ATTENTION:Formatter has to be set before the options are
set in order to reflect this change.setFormatter in interface AttributeWriteFormatter<VALUE>setFormatter in interface UiWidgetOptionsBase<VALUE>formatter - is the new Formatter to set.FormatterToStringpublic Formatter<VALUE> getFormatter()
Formatter of this object. It is used to
format a value of this object so it can be displayed to the end-user.getFormatter in interface AttributeReadFormatter<VALUE>Formatter.public boolean isAllowCustomInput()
options, that predefine values the user can
select from. Some widgets like a combo box allow the user to enter any text. If this method returns
false the entered text is only valid if it matches one of the predefined
options. The default is false. You may change this
by setting this flat to
true. Please note that depending on the datatype this might not make sense. E.g. if you are
using an Enum as value
and the user enters arbitrary text this can not be converted to a non existent enum constant and
therefore will only return null without causing a validation failure.isAllowCustomInput in interface AttributeReadAllowCustomInputtrue if custom input is allowed and accepted, false otherwise.public void setAllowCustomInput(boolean allowCustomInput)
allowCustomInput flag.setAllowCustomInput in interface AttributeWriteAllowCustomInputallowCustomInput - is the new value of AttributeReadAllowCustomInput.isAllowCustomInput().Copyright © 2001–2016 mmm-Team. All rights reserved.