Class WAjaxControl
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.WAjaxControl
-
- All Implemented Interfaces:
WComponent,WebComponent,Serializable
public class WAjaxControl extends AbstractWComponent
The WAjaxControl links an AJAX trigger component with one or more AJAX target components. Creating an AJAX trigger will result in an AJAX request being made on the 'onChange' event of the trigger element. The implication of this is that an AJAX trigger component should have an Action attached (usually via setActionOnChanged).
During an AJAX request the whole UI tree is serviced in the action phase but only the 'target' components of this control will be painted in the response.
- Since:
- 1.0.0
- Author:
- Christina Harris, Mark Reeves
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWAjaxControl.AjaxControlModelHolds the extrinsic state information of the component.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WAjaxControl(AjaxTrigger trigger)Create a WAjaxControl with a specified trigger component.WAjaxControl(AjaxTrigger trigger, AjaxTarget target)Create a WAjaxControl with specified trigger and target components.WAjaxControl(AjaxTrigger trigger, AjaxTarget[] targets)Create a WAjaxControl with specified trigger component and an array of target components.WAjaxControl(AjaxTrigger trigger, List<? extends AjaxTarget> targets)Create a WAjaxControl with specified trigger component and a List of target components.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddTarget(AjaxTarget target)Add a single target WComponent to this AJAX control.voidaddTargets(AjaxTarget[] targets)Add an array of target components that should be targets for this AJAX request.voidaddTargets(List<? extends AjaxTarget> targets)Add a list of target components that should be targets for this AJAX request.protected WAjaxControl.AjaxControlModelgetComponentModel()Returns the effective component model for this component.intgetDelay()Get the delay period, in milliseconds, between the WAjaxControl being rendered in the view and it being automatically triggered.intgetLoadCount()Deprecated.1.2.0 useisLoadOnce().protected WAjaxControl.AjaxControlModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.List<AjaxTarget>getTargets()Get the target WComponents that will be repainted as a consequence of the AJAX request.WComponent[]getTargetsArray()Get the target WComponents as an array.AjaxTriggergetTrigger()Get the component that will trigger the client to make the AJAX request.booleanisLoadOnce()protected WAjaxControl.AjaxControlModelnewComponentModel()Creates a new Component model.protected voidpreparePaintComponent(Request request)Override preparePaintComponent in order to register the components for the current request.voidsetDelay(int delay)Set a delay period, in milliseconds, between the WAjaxControl being rendered in the view and it being automatically triggered.voidsetLoadCount(int loadCount)Deprecated.1.2.0 usesetLoadOnce(boolean).voidsetLoadOnce(boolean loadOnce)Flag to indicate the the AJAX trigger should be fired once only.StringtoString()Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
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, handleRequest, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, 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, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
-
-
-
-
Constructor Detail
-
WAjaxControl
public WAjaxControl(AjaxTrigger trigger)
Create a WAjaxControl with a specified trigger component.- Parameters:
trigger- the WComponent that will fire the AJAX request on change
-
WAjaxControl
public WAjaxControl(AjaxTrigger trigger, AjaxTarget target)
Create a WAjaxControl with specified trigger and target components.- Parameters:
trigger- the WComponent that will fire the AJAX request on changetarget- the WComponent to be re-painted as a result of the AJAX request
-
WAjaxControl
public WAjaxControl(AjaxTrigger trigger, AjaxTarget[] targets)
Create a WAjaxControl with specified trigger component and an array of target components.- Parameters:
trigger- the WComponent that will fire the AJAX request on changetargets- the WComponents to be re-painted in the AJAX response
-
WAjaxControl
public WAjaxControl(AjaxTrigger trigger, List<? extends AjaxTarget> targets)
Create a WAjaxControl with specified trigger component and a List of target components.- Parameters:
trigger- the WComponent that will fire the AJAX request on changetargets- the WComponents to be re-painted in the AJAX responses
-
-
Method Detail
-
getTrigger
public AjaxTrigger getTrigger()
Get the component that will trigger the client to make the AJAX request.- Returns:
- the AJAX trigger
-
addTargets
public void addTargets(AjaxTarget[] targets)
Add an array of target components that should be targets for this AJAX request.- Parameters:
targets- the components to be repainted in the AJAX response
-
addTargets
public void addTargets(List<? extends AjaxTarget> targets)
Add a list of target components that should be targets for this AJAX request.- Parameters:
targets- the components that will be repainted for the AJAX request
-
addTarget
public void addTarget(AjaxTarget target)
Add a single target WComponent to this AJAX control.- Parameters:
target- a WComponent to be repainted
-
setLoadOnce
public void setLoadOnce(boolean loadOnce)
Flag to indicate the the AJAX trigger should be fired once only.- Parameters:
loadOnce- iftruethe target AJAX trigger only once for each load of a page
-
isLoadOnce
public boolean isLoadOnce()
- Returns:
trueif the trigger should be fired once only for each load of a page
-
setLoadCount
public void setLoadCount(int loadCount)
Deprecated.1.2.0 usesetLoadOnce(boolean).Set whether the trigger may fire once or an unlimited number of times. Any value > 0 will result in a trigger which can only fire once per page. See #495.- Parameters:
loadCount- The trigger count for this AJAX control.
-
getLoadCount
public int getLoadCount()
Deprecated.1.2.0 useisLoadOnce().Get the indicator of whether a trigger may fire once or an unlimited number of times. If loadCount > 0 the WAjaxControl may only fire once per page load. See #495.- Returns:
- 1 if the trigger may only load once, otherwise -1
-
getTargets
public List<AjaxTarget> getTargets()
Get the target WComponents that will be repainted as a consequence of the AJAX request.
When the AJAX request is triggered only the target component(s) will be re-painted. An empty list is returned if no targets have been defined.
- Returns:
- the target regions that are repainted in the AJAX response
-
getTargetsArray
public WComponent[] getTargetsArray()
Get the target WComponents as an array.
When the AJAX request is triggered only the target component(s) will be re-painted. If no targets have been registered then an empty array is returned.
- Returns:
- an array of AJAX target components
-
getDelay
public int getDelay()
Get the delay period, in milliseconds, between the WAjaxControl being rendered in the view and it being automatically triggered. A WAjaxControl with a delay > 0 will result in a request being made without a change to anyAjaxTriggercomponent.- Returns:
- the delay after page load before AJAX control triggered
-
setDelay
public void setDelay(int delay)
Set a delay period, in milliseconds, between the WAjaxControl being rendered in the view and it being automatically triggered. A WAjaxControl with a delay > 0 will result in a request being made without a change to any
AjaxTriggercomponent.The use of a delay may be useful for setting up a trigger which polls for changes in a part of a UI. See
WAjaxPollingRegion.If the trigger is part of a polling region (therefore it is itself updated and potentially re-triggers itself possibly many times) then the delay must not be less than 334.
- Parameters:
delay- the delay after page load before AJAX control triggered
-
preparePaintComponent
protected void preparePaintComponent(Request request)
Override preparePaintComponent in order to register the components for the current request.- Overrides:
preparePaintComponentin classAbstractWComponent- Parameters:
request- the request being responded to
-
toString
public String toString()
Description copied from class:AbstractWComponentCreates a String representation of this component; usually for debugging purposes.- Overrides:
toStringin classAbstractWComponent- Returns:
- a String representation of this component
-
newComponentModel
protected WAjaxControl.AjaxControlModel newComponentModel()
Creates a new Component model. For type safety only.- Overrides:
newComponentModelin classAbstractWComponent- Returns:
- a new AjaxControlModel.
-
getComponentModel
protected WAjaxControl.AjaxControlModel getComponentModel()
Description copied from class:AbstractWComponentReturns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModelin classAbstractWComponent- Returns:
- an AjaxControlModel; for type safety only
-
getOrCreateComponentModel
protected WAjaxControl.AjaxControlModel getOrCreateComponentModel()
Description copied from class:AbstractWComponentRetrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModelin classAbstractWComponent- Returns:
- an AjaxControlModel; for type safety only
-
-