Interface WComponent
-
- All Superinterfaces:
Serializable
,WebComponent
- All Known Subinterfaces:
AccessKeyable
,AjaxInternalTrigger
,AjaxTarget
,AjaxTrigger
,Autocompleteable
,AutocompleteableDate
,AutocompleteableEmail
,AutocompleteableMultiline
,AutocompleteableNumeric
,AutocompleteablePassword
,AutocompleteablePhone
,AutocompleteableText
,AutocompleteableURL
,Container
,Diagnosable
,DialogOpenTrigger
,Disableable
,DropZone
,ErrorPage
,Input
,Labelable
,Mandatable
,Marginable
,MenuContainer
,MenuItem
,MenuItemGroup
,MenuItemSelectable
,MenuSelectContainer
,MultiInputComponent
,MutableContainer
,NamingContextable
,Placeholderable
,SubordinateTarget
,SubordinateTrigger
,Targetable
- All Known Implementing Classes:
AbstractContainer
,AbstractInput
,AbstractMutableContainer
,AbstractNamingContextContainer
,AbstractTransientDataContainer
,AbstractWComponent
,AbstractWComponent.WComponentRef
,AbstractWFieldIndicator
,AbstractWMultiSelectList
,AbstractWSelectList
,AbstractWSingleSelectList
,DefaultTransientDataContainer
,DefaultWComponent
,FatalErrorPage
,ProfileContainer
,RadioButtonGroup
,UicProfileButton
,WAbbrText
,WAjaxControl
,WAjaxPollingRegion
,WApplication
,WAudio
,WBeanComponent
,WBeanContainer
,WButton
,WCancelButton
,WCardManager
,WCheckBox
,WCheckBoxSelect
,WCollapsible
,WCollapsibleToggle
,WColumn
,WColumnLayout
,WComponentGroup
,WConfirmationButton
,WContainer
,WContent
,WContentLink
,WDataRenderer
,WDataTable
,WDataTableRowRenderer
,WDateField
,WDecoratedLabel
,WDefinitionList
,WDialog
,WDropdown
,WEditableImage
,WEmailField
,WField
,WFieldErrorIndicator
,WFieldLayout
,WFieldSet
,WFieldWarningIndicator
,WFigure
,WFileWidget
,WFilterText
,WHeading
,WHiddenComment
,WHorizontalRule
,WImage
,WImageEditor
,WInternalLink
,WInvisibleContainer
,WLabel
,WLink
,WList
,WMenu
,WMenuItem
,WMenuItemGroup
,WMessageBox
,WMessages
,WMultiDropdown
,WMultiFileWidget
,WMultiSelect
,WMultiSelectPair
,WMultiTextField
,WNamingContext
,WNumberField
,WPanel
,WPartialDateField
,WPasswordField
,WPhoneNumberField
,WPopup
,WPrintButton
,WProgressBar
,WRadioButton
,WRadioButtonSelect
,WRepeater
,WRepeater.WRepeatRoot
,WRow
,WSection
,WSelectToggle
,WSeparator
,WShuffler
,WSingleSelect
,WSkipLinks
,WStyledText
,WSubMenu
,WSubordinateControl
,WSuggestions
,WTab
,WTabGroup
,WTable
,WTable.TableRepeater
,WTableColumn
,WTableRepeater
,WTableRowRenderer
,WTabSet
,WTemplate
,WText
,WTextArea
,WTextField
,WTimeoutWarning
,WToggleButton
,WTree
,WValidationErrors
,WVideo
,WWindow
public interface WComponent extends WebComponent
The WComponent interface.In the WComponent library, only the
AbstractWComponent
implements this interface directly. All other components extend from the abstract class.There are a few other interfaces which extend this one. They are used to provide additional functionality (e.g.
Container
which can contain other components), or used as a marker to denote capabilities (e.g.AjaxTarget
can be updated with AJAX).- Author:
- Yiannis Paschalidis, Jonathan Austin
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_APPLICATION_ID
The default application context id.static String
DEFAULT_INTERNAL_ID
The default internal id name for components with no parent.static String
DEFAULT_NO_ID
The default id name for components with no parent and no id name set.static String
ID_CONTEXT_SEPERATOR
The default id/name separator character.static String
ID_FRAMEWORK_ASSIGNED_SEPERATOR
The reserved character to prefix framework assigned ids.static String
ID_VALIDATION_PATTERN
User assigned IDs must start with a letter and followed by letters, digits or underscores.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
addHtmlClass(HtmlClassProperties className)
Append a value to the HTML class name for this component from a set of preset values.void
addHtmlClass(String className)
Append value to the HTML class name for this component.void
forward(String url)
Applications can call this method during event handling to indicate that we should forward to a given url.String
getAccessibleText()
Deprecated.use getToolTipSerializable
getAttribute(String key)
Retrieves an arbitrary attribute which has been previously associated with this component.String
getBaseUrl()
Exposes the base URL for this environment.Environment
getEnvironment()
Retrieves the environment for the current session.Headers
getHeaders()
Retrieves the headers.String
getHtmlClass()
Returns the HTML class name string to apply to a component.Set
getHtmlClasses()
String
getId()
Return an identifier for this component, generating one if necessary.String
getIdName()
String
getInternalId()
WLabel
getLabel()
String
getName()
Deprecated.No longer used.Container
getParent()
int
getTabIndex()
Deprecated.1.4 causes a11y issues, no replacement.String
getTag()
Deprecated.UseWTemplate
instead.String
getToolTip()
Retrieves the component's tool tip.void
handleRequest(Request request)
Subclasses should override this method in order to provide specific request handling logic.boolean
hasTabIndex()
Deprecated.1.4 causes a11y issues, no replacement.void
invokeLater(Runnable runnable)
Adds a runnable that will be processed after the completion of the current serviceRequest method.boolean
isDefaultState()
WComponents must implement this method in order to protect any session based information they store from being incorrectly removed by thetidyUpUIContextForTree()
method.boolean
isHidden()
Indicates whether this component is hidden.boolean
isInitialised()
Optionally use this flag to test if some arbitrary initialisation has been performed by this component.boolean
isLocked()
Indicates whether this component is locked.boolean
isTracking()
Returns true if this component should be tracked.boolean
isTrackingEnabled()
Returns true if tracking is enabled for this component.This flag is used byisTracking()
.boolean
isValidate()
Indicates whether this component should take part in validation processing.boolean
isVisible()
Indicates whether this component is visible.void
paint(RenderContext renderContext)
Paints the component by rendering it in the given context.void
preparePaint(Request request)
Prepares this component and all child components for immediate painting (e.g. rendering to XML).Serializable
removeAttribute(String key)
Removes an arbitrary attribute.void
removeHtmlClass(HtmlClassProperties className)
Remove a value from the set of HTML class name values added to the current component.void
removeHtmlClass(String className)
Remove a value from the set of HTML class name values added to the current component.void
reset()
Resets this component and its children to their initial state.void
serviceRequest(Request request)
This is the main entry point during request handling.void
setAccessibleText(String text, Serializable... args)
Deprecated.use setToolTipvoid
setAttribute(String key, Serializable value)
Associates an arbitrary attribute with this component.void
setEnvironment(Environment environment)
Sets the environment.void
setFocussed()
Requests that this component be given keyboard focus when rendered.void
setHtmlClass(HtmlClassProperties className)
Sets additional HTML class name for this component from a set of preset values.void
setHtmlClass(String className)
Sets additional HTML class name string for this component.void
setIdName(String idName)
Set the component identifier of this Component (if any).void
setInitialised(boolean flag)
Optionally use this flag to store whether some arbitrary initialisation has been performed by this component on the given session.void
setLocked(boolean lock)
The shared attributes of a component (and all its children) can be locked, preventing users/developers from making further updates.void
setTag(String tag)
Deprecated.UseWTemplate
instead.void
setToolTip(String text, Serializable... args)
Sets the component's tool tip.void
setTrackingEnabled(boolean track)
Sets the flag if tracking is enabled for this component.void
setValidate(boolean flag)
Sets whether this component should take part in validation processing.void
setVisible(boolean visible)
Sets the visibility of this component.void
showErrorIndicators(List<Diagnostic> diags)
This does not affect the diag list at all.void
showWarningIndicators(List<Diagnostic> diags)
This does not affect the diag list at all.void
tidyUpUIContextForTree()
This method removes unnecessary component models from the user session for this component and all its descendants.void
validate(List<Diagnostic> diags)
The validate method should be called by anAction
, orValidatingAction
at points in the application lifecycle where it makes sense to perform validation.
-
-
-
Field Detail
-
ID_CONTEXT_SEPERATOR
static final String ID_CONTEXT_SEPERATOR
The default id/name separator character.- See Also:
- Constant Field Values
-
ID_FRAMEWORK_ASSIGNED_SEPERATOR
static final String ID_FRAMEWORK_ASSIGNED_SEPERATOR
The reserved character to prefix framework assigned ids.- See Also:
- Constant Field Values
-
DEFAULT_APPLICATION_ID
static final String DEFAULT_APPLICATION_ID
The default application context id.- See Also:
- Constant Field Values
-
DEFAULT_NO_ID
static final String DEFAULT_NO_ID
The default id name for components with no parent and no id name set.- See Also:
- Constant Field Values
-
DEFAULT_INTERNAL_ID
static final String DEFAULT_INTERNAL_ID
The default internal id name for components with no parent.- See Also:
- Constant Field Values
-
ID_VALIDATION_PATTERN
static final String ID_VALIDATION_PATTERN
User assigned IDs must start with a letter and followed by letters, digits or underscores.- See Also:
- Constant Field Values
-
-
Method Detail
-
getInternalId
String getInternalId()
- Returns:
- the internal identifier of this Component based on its position in the component tree.
-
getIdName
String getIdName()
- Returns:
- the component identifier of this Component (if any).
-
setIdName
void setIdName(String idName)
Set the component identifier of this Component (if any). Component identifiers must obey the following syntax restrictions:- Must not be a zero-length String.
- First character must be a letter.
- Underscore ('_') as the first character is reserved by the framework.
- Subsequent characters must be a letter, a digit or an underscore ('_').
The specified identifier must be unique among all the components that are descendents of the nearest ancestor Component that is an active
NamingContextable
.- Parameters:
idName
- the id name
-
getName
@Deprecated String getName()
Deprecated.No longer used. UsegetId()
instead.Retrieves the name for this WComponent.- Specified by:
getName
in interfaceWebComponent
- Returns:
- the name for this WComponent in the current context.
-
getId
String getId()
Return an identifier for this component, generating one if necessary.The implementation must follow these steps in determining the Id:
If has id name set:- Find the closest ancestor to this component in the tree hierarchy that is an active
NamingContextable
. - If no context found, then let the ID be the idname.
- If a context found, then let the ID be
NamingContextable.getNamingContextId()
+ID_CONTEXT_SEPERATOR
+ id name.
- If the component's parent is null, then let the ID be
DEFAULT_NO_ID
. - If has a parent, then let the ID prefix be parent.getId() or parent.getNamingContextID() +
ID_CONTEXT_SEPERATOR
if the parent is an active NamingContext. Then let the ID be prefix + generate unique id.
- Specified by:
getId
in interfaceWebComponent
- Returns:
- the id for this WComponent in the current context.
- Find the closest ancestor to this component in the tree hierarchy that is an active
-
serviceRequest
void serviceRequest(Request request)
This is the main entry point during request handling. Only the "top-level" component will have this method called - other components will have
The basic workflow is:handleRequest(Request)
called. For efficiency, onlyvisible
components are asked to handle the request.- Collate the list of visible components, in depth-first order. Depth-first traversal is used to ensure that when a parent component's handleRequest method is called, all of its children have already handled the request and are in a stable state.
- Call handle request for each visible component found, in order.
- At this point, all the components should be in a stable state, and any runnables added using
invokeLater(Runnable)
will be invoked. These runnables can include e.g.Actions
on buttons.
Applications should not call this method directly.
- Specified by:
serviceRequest
in interfaceWebComponent
- Parameters:
request
- the request being responded to.
-
invokeLater
void invokeLater(Runnable runnable)
Adds a runnable that will be processed after the completion of the current serviceRequest method. This method is intended to be called from subcomponents' handleRequest methods, to permit processing to continue once the entire WComponent tree has been updated from the incoming HTTP request.
If this method is invoked more than once, each Runnable will be invoked in turn.
- Parameters:
runnable
- the Runnable to execute after the serviceRequest method has otherwise completed.
-
handleRequest
void handleRequest(Request request)
Subclasses should override this method in order to provide specific request handling logic. For example, a text field may set its value to the value of a request parameter.- Parameters:
request
- the request being responded to.
-
forward
void forward(String url)
Applications can call this method during event handling to indicate that we should forward to a given url. The event handling will complete and the forwarding will take place before painting.- Parameters:
url
- the URL to forward to
-
preparePaint
void preparePaint(Request request)
Prepares this component and all child components for immediate painting (e.g. rendering to XML). Note that the parent's preparePaint method is called before the childrens'.- Specified by:
preparePaint
in interfaceWebComponent
- Parameters:
request
- the request being responded to.
-
paint
void paint(RenderContext renderContext)
Paints the component by rendering it in the given context.- Specified by:
paint
in interfaceWebComponent
- Parameters:
renderContext
- the context to render to.
-
validate
void validate(List<Diagnostic> diags)
The validate method should be called by an
Action
, orValidatingAction
at points in the application lifecycle where it makes sense to perform validation.No side effect of displaying error markers implied by this. This is a pure "function" except that it stores the results in the
diags
list.It is the responsibility of the validatable component to call any of its children that may also require validation.
- Parameters:
diags
- the list into which any validation diagnostics are added.
-
showErrorIndicators
void showErrorIndicators(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.
It is the responsibility of the validatable component to call any of its children that may also be validatable.
- Parameters:
diags
- the list of current validation diagnostics.
-
showWarningIndicators
void showWarningIndicators(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.
It is the responsibility of the validatable component to call any of its children that may also be validatable. The default implemntation does nothing.
- Parameters:
diags
- the list of diagnostics for this component.
-
setLocked
void setLocked(boolean lock)
The shared attributes of a component (and all its children) can be locked, preventing users/developers from making further updates. However, attribute values can still be updated on a per session basis.
This method should normally never be called from application code.
- Parameters:
lock
- true to lock the component, false to unlock
-
isLocked
boolean isLocked()
Indicates whether this component is locked. If the component is locked, shared attribute values can not be updated.- Returns:
- true if the component is locked, false if not.
-
isInitialised
boolean isInitialised()
Optionally use this flag to test if some arbitrary initialisation has been performed by this component.- Returns:
- true if the component has been marked as initialised, false otherwise.
- See Also:
setInitialised(boolean)
-
setInitialised
void setInitialised(boolean flag)
Optionally use this flag to store whether some arbitrary initialisation has been performed by this component on the given session. This should normally only be used after the UI has been constructed.- Parameters:
flag
- the initialised flag.
-
isValidate
boolean isValidate()
Indicates whether this component should take part in validation processing.- Returns:
- true if this component is validateable, false if not.
-
setValidate
void setValidate(boolean flag)
Sets whether this component should take part in validation processing.- Parameters:
flag
- true if this component should be validated, false if not.
-
isVisible
boolean isVisible()
Indicates whether this component is visible. Invisible components are normally excluded from all event handling and painting.- Returns:
- true if this component is visible, false if invisible.
-
setVisible
void setVisible(boolean visible)
Sets the visibility of this component. Invisible components are normally excluded from all event handling and painting.- Parameters:
visible
- true to set this component visible, false for invisible.
-
isHidden
boolean isHidden()
Indicates whether this component is hidden. Hidden components take part in event handling and painting, but are not visible on the client.- Returns:
- true if this component is hidden, false if displayed.
-
hasTabIndex
@Deprecated boolean hasTabIndex()
Deprecated.1.4 causes a11y issues, no replacement.Indicates whether this component has a tab index.- Returns:
- false - For the moment, turn off the tab index feature and see what happens.
-
getTabIndex
@Deprecated int getTabIndex()
Deprecated.1.4 causes a11y issues, no replacement.- Returns:
- the tab index for this component.
-
getLabel
WLabel getLabel()
- Returns:
- the label associated with this component, or null if there is no label.
-
setFocussed
void setFocussed()
Requests that this component be given keyboard focus when rendered.
-
reset
void reset()
Resets this component and its children to their initial state.
-
tidyUpUIContextForTree
void tidyUpUIContextForTree()
This method removes unnecessary component models from the user session for this component and all its descendants. A component model is deemed unnecessary when it has the same state as the component's default component model.
-
isDefaultState
boolean isDefaultState()
WComponents must implement this method in order to protect any session based information they store from being incorrectly removed by the
tidyUpUIContextForTree()
method.It is possible you can write a more exact check for the default state here than the method on the component model itself can provide.
- Returns:
- true if the component is in it's default state, otherwise false.
-
getParent
Container getParent()
- Returns:
- the current parent of this component.
-
getTag
@Deprecated String getTag()
Deprecated.UseWTemplate
instead.Retrieves the tag used to identify this component in a Velocity template.- Returns:
- the component's tag.
-
setTag
@Deprecated void setTag(String tag)
Deprecated.UseWTemplate
instead.Sets the tag used to identify this component in a Velocity template.- Parameters:
tag
- the component's tag to set.
-
getEnvironment
Environment getEnvironment()
Retrieves the environment for the current session. If there is no environment for the session, a dummy environment is returned.- Returns:
- the environment for the user session.
-
setEnvironment
void setEnvironment(Environment environment)
Sets the environment.- Parameters:
environment
- the environment to set.
-
getHeaders
Headers getHeaders()
Retrieves the headers.- Returns:
- the headers.
-
getBaseUrl
String getBaseUrl()
Exposes the base URL for this environment. Renderers can call this method to construct URIs to sub-resources. The baseurl is ultimately derived from com.github.bordertech.wcomponents.Environment- Returns:
- the base URL
-
setAttribute
void setAttribute(String key, Serializable value)
Associates an arbitrary attribute with this component.- Parameters:
key
- the attribute key.value
- the attribute value.
-
getAttribute
Serializable getAttribute(String key)
Retrieves an arbitrary attribute which has been previously associated with this component.- Parameters:
key
- the attribute key.- Returns:
- value the attribute value if set, otherwise null.
-
removeAttribute
Serializable removeAttribute(String key)
Removes an arbitrary attribute.- Parameters:
key
- the attribute key.- Returns:
- the value for the attribute which was removed, or null if no attribute was found with the given key.
-
setToolTip
void setToolTip(String text, Serializable... args)
Sets the component's tool tip. Note that not all components support displaying tool tips.- Parameters:
text
- the tool tip text, usingMessageFormat
syntax.args
- optional arguments for the message format string.
-
getToolTip
String getToolTip()
Retrieves the component's tool tip.- Returns:
- the component's tool tip.
-
setAccessibleText
void setAccessibleText(String text, Serializable... args)
Deprecated.use setToolTipSets the text used by screen readers to describe the component.- Parameters:
text
- the screen reader text, usingMessageFormat
syntax.args
- optional arguments for the message format string.
-
getAccessibleText
String getAccessibleText()
Deprecated.use getToolTipRetrieves the text used by screen readers to describe the component.- Returns:
- the screen reader text.
-
setTrackingEnabled
void setTrackingEnabled(boolean track)
Sets the flag if tracking is enabled for this component. This flag is used byisTracking()
.- Parameters:
track
- set true if tracking is enabled for this component.
-
isTrackingEnabled
boolean isTrackingEnabled()
Returns true if tracking is enabled for this component.This flag is used byisTracking()
.- Returns:
- true if tracking is enabled for this component.
-
isTracking
boolean isTracking()
Returns true if this component should be tracked.A component will only be tracked if
setTrackingEnabled(boolean)
is set true and the component has an id set viasetIdName(String)
. If the id has not been set, then the id used for tracking will be dynamic and constantly changing which makes it useless for analysing.- Returns:
- true if this component should be tracked.
-
setHtmlClass
void setHtmlClass(String className)
Sets additional HTML class name string for this component. Multiple HTML class names may be added to an instance of a component using a space separated string. Some values in the HTML class name attribute are determined in the theme and are used for core functionality and styling.- Parameters:
className
- the HTML class attribute's value to add to the component
-
setHtmlClass
void setHtmlClass(HtmlClassProperties className)
Sets additional HTML class name for this component from a set of preset values.- Parameters:
className
- the HTML class attribute's value to add to the component derived from the utility enum
-
addHtmlClass
void addHtmlClass(String className)
Append value to the HTML class name for this component.- Parameters:
className
- the HTML class attribute's value to add to the component
-
addHtmlClass
void addHtmlClass(HtmlClassProperties className)
Append a value to the HTML class name for this component from a set of preset values.- Parameters:
className
- the HTML class attribute's value to add to the component derived from the utility enum
-
getHtmlClass
String getHtmlClass()
Returns the HTML class name string to apply to a component. Some values in the HTML class name attribute are determined in the theme and are used for core functionality and styling. This method will only return class name values which are added in the application, it has no knowledge of theme's class names.- Returns:
- the value to add to the HTML class attribute of the output component
-
getHtmlClasses
Set getHtmlClasses()
- Returns:
- the HTML class list HashSet for this component
-
removeHtmlClass
void removeHtmlClass(String className)
Remove a value from the set of HTML class name values added to the current component.- Parameters:
className
- the value to remove
-
removeHtmlClass
void removeHtmlClass(HtmlClassProperties className)
Remove a value from the set of HTML class name values added to the current component.- Parameters:
className
- the property representing the value to remove
-
-