public abstract class AbstractInput extends WBeanComponent implements Input
Modifier and Type | Class and Description |
---|---|
static class |
AbstractInput.InputModel
InputModel holds Extrinsic state management of the field.
|
AbstractWComponent.WComponentRef
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
Constructor and Description |
---|
AbstractInput() |
Modifier and Type | Method and Description |
---|---|
void |
addValidator(FieldValidator validator)
Adds a validator to the input field.
|
protected boolean |
beforeHandleRequest(Request request)
Handle before handle request processing.
|
protected Diagnostic |
createMandatoryDiagnostic()
This method is called by validateComponent to create the mandatory diagnostic error message if the mandatory
validation check does not pass.
|
protected void |
doHandleChanged()
Perform change logic for this component.
|
protected abstract boolean |
doHandleRequest(Request request)
Specific handle request processing for an input component is provided here.
|
String |
getActionCommand()
Same as {#getValueAsString()}.
|
Object |
getActionObject()
Returns the data object that has been associated with this input component, else null.
|
Action |
getActionOnChange() |
protected AbstractInput.InputModel |
getComponentModel()
Returns the effective component model for this component.
|
WButton |
getDefaultSubmitButton() |
List<Diagnostic> |
getDiagnostics(int severity) |
protected AbstractInput.InputModel |
getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified.
|
Iterator<FieldValidator> |
getValidators() |
Object |
getValue()
Provide the value of the component returned by
DataBound.getData() in the correct format. |
String |
getValueAsString()
Retrieves a String representation of the input field's value.
|
void |
handleRequest(Request request)
Override handleRequest in order to perform consistent processing for input components.
|
boolean |
isChangedInLastRequest()
Indicates if the input component was changed in the last request.
|
boolean |
isCurrentAjaxTrigger() |
boolean |
isDisabled()
Indicates whether the Disableable is disabled.
|
boolean |
isEmpty()
Indicates whether this input field is empty.
|
boolean |
isMandatory()
Indicates whether or not this component is mandatory.
|
protected boolean |
isPresent(Request request)
Determine if this component is on the Request.
|
boolean |
isReadOnly()
Indicates whether the input is read only in the given context.
|
protected AbstractInput.InputModel |
newComponentModel()
Creates a new model appropriate for this component.
|
void |
setActionObject(Object data)
Associates this input with a data object that can be easily accessed in the execute() method of the associated
Action.
|
void |
setActionOnChange(Action actionOnChange)
Sets the action that you want run if the input is changed by the user.
|
protected void |
setChangedInLastRequest(boolean changed)
Set the changed flag to indicate if the component changed in the last request.
|
void |
setDefaultSubmitButton(WButton defaultSubmitButton)
Sets the button that should be submitted when the user hits enter key and cursor is inside this input field.
|
void |
setDisabled(boolean disabled)
Sets whether the Disableable is disabled.
|
void |
setMandatory(boolean mandatory)
Set whether or not this component is mandatory.
|
void |
setMandatory(boolean mandatory,
String message)
Set whether or not this input is mandatory, and customise the error message that will be displayed.
|
void |
setReadOnly(boolean readOnly)
Sets whether the input is read only.
|
protected void |
showErrorIndicatorsForComponent(List<Diagnostic> diags)
This does not affect the diag list at all.
|
protected void |
showIndicatorsForComponent(List<Diagnostic> diags,
int severity)
Iterates over the
Diagnostic s and finds the diagnostics that related to the current component. |
protected void |
showWarningIndicatorsForComponent(List<Diagnostic> diags)
This does not affect the diag list at all.
|
String |
toString()
Creates a String representation of this component; usually for debugging purposes.
|
protected void |
validateComponent(List<Diagnostic> diags)
Override WComponent's validatorComponent in order to use the validators which have been added to this input
field.
|
addBeanToScratchMap, doUpdateBeanValue, getBean, getBeanFromScratchMap, getBeanId, getBeanProperty, getBeanProvider, getBeanScratchMap, getBeanValue, getData, isBeanInScratchMap, isChanged, isSearchAncestors, isUseRequestScopeScratchMap, removeBeanFromScratchMap, resetData, setBean, setBeanId, setBeanProperty, setBeanProvider, setData, setSearchAncestors, updateBeanValue
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContext, tidyUpUIContextForTree, validate, writeReplace
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getRequestValue
isSearchAncestors, setBean
getBeanId, setBeanId, setBeanProvider
getBean, getBeanProperty, getBeanValue, setBeanProperty
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
public void addValidator(FieldValidator validator)
ValidatingAction
or an explicit call to WComponent.validate(List)
will trigger validation on a
WComponent tree.addValidator
in interface Input
validator
- the validator to add.public Iterator<FieldValidator> getValidators()
getValidators
in interface Input
protected void validateComponent(List<Diagnostic> diags)
validateComponent
in class AbstractWComponent
diags
- the list into which any validation diagnostics are added.protected Diagnostic createMandatoryDiagnostic()
This method is called by validateComponent to create the mandatory diagnostic error message if the mandatory validation check does not pass.
Subclasses may override this method to customise the message, however in most cases it is easier to supply a custom error message pattern to the setMandatory method.
public void setActionOnChange(Action actionOnChange)
setActionOnChange
in interface Input
actionOnChange
- the action to execute when the input is changed by the user.public Action getActionOnChange()
getActionOnChange
in interface Input
public Object getActionObject()
getActionObject
in interface Input
public void setActionObject(Object data)
setActionObject
in interface Input
data
- the data object.public String getActionCommand()
getActionCommand
in interface Input
public void setDefaultSubmitButton(WButton defaultSubmitButton)
setDefaultSubmitButton
in interface Input
defaultSubmitButton
- the default submit button for this field.public WButton getDefaultSubmitButton()
getDefaultSubmitButton
in interface Input
public void setMandatory(boolean mandatory, String message)
setMandatory
in interface Input
mandatory
- true for mandatory, false for optional.message
- the message to display to the user on mandatory validation failure.public void setMandatory(boolean mandatory)
setMandatory
in interface Mandatable
mandatory
- true for mandatory, false for optional.public boolean isMandatory()
isMandatory
in interface Mandatable
public boolean isReadOnly()
isReadOnly
in interface Input
public void setReadOnly(boolean readOnly)
setReadOnly
in interface Input
readOnly
- if true, the input is read only. If false, it is editable.public boolean isDisabled()
isDisabled
in interface Disableable
public void setDisabled(boolean disabled)
setDisabled
in interface Disableable
disabled
- if true, the Disableable is disabled. If false, it is enabled.public final void handleRequest(Request request)
To protect against client-side tampering of the request, disabled/readonly input fields will not have their handle request processing performed.
This method will call doHandleRequest(Request)
for input components to process the request. If the input
component has changed, then this method will call doHandleChanged()
and set the
isChangedInLastRequest()
flag.
handleRequest
in interface WComponent
handleRequest
in class AbstractWComponent
request
- the request being responded to.protected boolean beforeHandleRequest(Request request)
request
- the request being responded to.protected abstract boolean doHandleRequest(Request request)
Input components are required to determine if the component has changed in the request, set the component data to the new value (if changed) and return the changed flag.
request
- the request being responded to.protected void doHandleChanged()
Reset focus ONLY if the current Request is an Ajax request. See https://github.com/BorderTech/wcomponents/issues/501.
protected boolean isPresent(Request request)
request
- the request being responded to.public Object getValue()
DataBound.getData()
in the correct format.
If required, this method can convert the data into the correct type and also do any validation before the value is used.
getValue
in interface Input
DataBound.getData()
in the correct format.public String getValueAsString()
getValueAsString
in interface Input
public boolean isEmpty()
public boolean isChangedInLastRequest()
isChangedInLastRequest
in interface Input
protected void setChangedInLastRequest(boolean changed)
changed
- true if the value changed in the requestpublic final boolean isCurrentAjaxTrigger()
true
if the current Input is also the current Ajax trigger.public String toString()
AbstractWComponent
toString
in class AbstractWComponent
protected void showIndicatorsForComponent(List<Diagnostic> diags, int severity)
Diagnostic
s and finds the diagnostics that related to the current component.diags
- A List of Diagnostic objects.severity
- A Diagnostic severity code. e.g. Diagnostic.ERROR
protected final void showErrorIndicatorsForComponent(List<Diagnostic> diags)
This does not affect the diag list at all. The ValidatableComponent should visually mark any fields or blocks that have errors in the given diag list.
showErrorIndicatorsForComponent
in class AbstractWComponent
diags
- the list of diagnostics for this component.protected final void showWarningIndicatorsForComponent(List<Diagnostic> diags)
This does not affect the diag list at all. The ValidatableComponent should visually mark any fields or blocks that have warnings in the given diag list.
showWarningIndicatorsForComponent
in class AbstractWComponent
diags
- the list of diagnostics for this component.public List<Diagnostic> getDiagnostics(int severity)
getDiagnostics
in interface Diagnosable
severity
- the diagnostic level we are interested inprotected AbstractInput.InputModel newComponentModel()
newComponentModel
in class WBeanComponent
BeanAndProviderBoundComponentModel
.protected AbstractInput.InputModel getComponentModel()
getComponentModel
in class WBeanComponent
protected AbstractInput.InputModel getOrCreateComponentModel()
getOrCreateComponentModel
in class WBeanComponent
Copyright © 2021. All rights reserved.