Class UIContextDelegate
- java.lang.Object
-
- com.github.bordertech.wcomponents.UIContextDelegate
-
- All Implemented Interfaces:
UIContext,Serializable
- Direct Known Subclasses:
AbstractContainerHelper.UIContextWrap,WRepeater.SubUIContext
public class UIContextDelegate extends Object implements UIContext
UIContextDelegate implements UIContext, but delegates all the work to a backing context. This allows us to easily write UIContext extensions that only need to change the behaviour of a few methods.- Since:
- 1.0.0
- Author:
- Yiannis Paschalidis
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedUIContextDelegate(UIContext backing)Creates a UIContextDelegate.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclearRequestScratchMap()Reserved for internal framework use.voidclearRequestScratchMap(WComponent component)Reserved for internal framework use.voidclearScratchMap()Reserved for internal framework use.voidclearScratchMap(WComponent component)Reserved for internal framework use.voiddoInvokeLaters()Runs the runnables that were added usingUIContext.invokeLater(Runnable).UIContextgetBacking()SetgetComponents()longgetCreationTime()Returns the creation time of this UIContext, which can be used to approximate the user session creation time.EnvironmentgetEnvironment()If we've got an environment, return it.WComponentgetFocussed()StringgetFocussedId()ObjectgetFwkAttribute(String name)Reserved for internal framework use.SetgetFwkAttributeNames()Reserved for internal framework use.HeadersgetHeaders()LocalegetLocale()Retrieves the locale for this context.WebModelgetModel(WebComponent component)Get the extrinsic state information for the given component.static UIContextgetPrimaryUIContext(UIContext uic)Deprecated.Map<Object,Object>getRequestScratchMap(WComponent component)Reserved for internal framework use.MapgetScratchMap(WComponent component)Reserved for internal framework use.WComponentgetUI()voidinvokeLater(UIContext uic, Runnable runnable)Adds a runnable to the list of runnables to be invoked later against the given UIContext.voidinvokeLater(Runnable runnable)Adds a runnable to the list of runnables to be invoked later.booleanisDummyEnvironment()booleanisFocusRequired()Indicates whether a component needs to be given focus.voidremoveFwkAttribute(String name)Reserved for internal framework use.voidremoveModel(WebComponent component)Removes the extrinsic state information for the given component.protected voidsetBacking(UIContext backing)Sets the backing context.voidsetEnvironment(Environment environment)Explicitly sets the environment.voidsetFocusRequired(boolean b)Sets whether a component needs to be given focus.voidsetFocussed(WComponent component)Sets the component in this UIC which is to be the focus of the client browser cursor.voidsetFocussed(WComponent component, UIContext uic)Sets the component in this UIC which is to be the focus of the client browser cursor.voidsetFwkAttribute(String name, Object value)Reserved for internal framework use.voidsetLocale(Locale locale)Sets the locale for this context.voidsetModel(WebComponent component, WebModel model)Stores the extrinsic state information for the given component.voidsetUI(WComponent ui)For use by internal framework code only.
-
-
-
Constructor Detail
-
UIContextDelegate
protected UIContextDelegate(UIContext backing)
Creates a UIContextDelegate. This is marked protected, as it doesn't make sense to create an instance of the delegate without changing behaviour.- Parameters:
backing- the backing context.
-
-
Method Detail
-
setBacking
protected void setBacking(UIContext backing)
Sets the backing context.- Parameters:
backing- the backing context.
-
clearScratchMap
public void clearScratchMap()
Reserved for internal framework use. Clears the scratch map with phase scope.- Specified by:
clearScratchMapin interfaceUIContext
-
clearScratchMap
public void clearScratchMap(WComponent component)
Reserved for internal framework use. Clears the scratch map with phase scope for the given component.- Specified by:
clearScratchMapin interfaceUIContext- Parameters:
component- the component to clear the scratch map for.
-
doInvokeLaters
public void doInvokeLaters()
Runs the runnables that were added usingUIContext.invokeLater(Runnable).- Specified by:
doInvokeLatersin interfaceUIContext
-
getComponents
public Set getComponents()
- Specified by:
getComponentsin interfaceUIContext- Returns:
- the set of WComponents that are storing a model.
-
getCreationTime
public long getCreationTime()
Returns the creation time of this UIContext, which can be used to approximate the user session creation time.- Specified by:
getCreationTimein interfaceUIContext- Returns:
- the creation time of this UIContext.
-
getEnvironment
public Environment getEnvironment()
If we've got an environment, return it. Otherwise return a dummy environment.- Specified by:
getEnvironmentin interfaceUIContext- Returns:
- the current environment.
-
getFocussed
public WComponent getFocussed()
- Specified by:
getFocussedin interfaceUIContext- Returns:
- the focussed component for this UI.
-
getFocussedId
public String getFocussedId()
- Specified by:
getFocussedIdin interfaceUIContext- Returns:
- the unique id of the focussed component for this UI.
-
getFwkAttribute
public Object getFwkAttribute(String name)
Reserved for internal framework use. Retrieves a framework attribute.- Specified by:
getFwkAttributein interfaceUIContext- Parameters:
name- the attribute name.- Returns:
- the framework attribute with the given name.
-
getFwkAttributeNames
public Set getFwkAttributeNames()
Reserved for internal framework use.- Specified by:
getFwkAttributeNamesin interfaceUIContext- Returns:
- the names of all attributes bound to this context.
-
getHeaders
public Headers getHeaders()
- Specified by:
getHeadersin interfaceUIContext- Returns:
- the headers instance for this UIContext.
-
getModel
public WebModel getModel(WebComponent component)
Get the extrinsic state information for the given component.
-
getScratchMap
public Map getScratchMap(WComponent component)
Reserved for internal framework use. Retrieves a scratch area with phse scope, where data can be temporarily stored. WComponents must not rely on data being available in the scratch area after each phase.- Specified by:
getScratchMapin interfaceUIContext- Parameters:
component- the component to retrieve the scratch map for.- Returns:
- the scratch map with phase scope for the given component.
-
getUI
public WComponent getUI()
-
invokeLater
public void invokeLater(Runnable runnable)
Adds a runnable to the list of runnables to be invoked later. The runnable will be invoked against this UIContext.- Specified by:
invokeLaterin interfaceUIContext- Parameters:
runnable- the runnable to add
-
invokeLater
public void invokeLater(UIContext uic, Runnable runnable)
Adds a runnable to the list of runnables to be invoked later against the given UIContext.- Specified by:
invokeLaterin interfaceUIContext- Parameters:
uic- the context to run the runnable in.runnable- the runnable to add
-
isDummyEnvironment
public boolean isDummyEnvironment()
- Specified by:
isDummyEnvironmentin interfaceUIContext- Returns:
- true if the current environment is a 'dummy' environment.
-
isFocusRequired
public boolean isFocusRequired()
Indicates whether a component needs to be given focus.- Specified by:
isFocusRequiredin interfaceUIContext- Returns:
- true if focus needs to be set.
- See Also:
UIContext.setFocussed(WComponent, UIContext)
-
removeFwkAttribute
public void removeFwkAttribute(String name)
Reserved for internal framework use. Removes a framework attribute.- Specified by:
removeFwkAttributein interfaceUIContext- Parameters:
name- the attribute name.
-
removeModel
public void removeModel(WebComponent component)
Removes the extrinsic state information for the given component. Note that this is not recursive for the children.- Specified by:
removeModelin interfaceUIContext- Parameters:
component- the component to remove the model for.
-
setEnvironment
public void setEnvironment(Environment environment)
Explicitly sets the environment.- Specified by:
setEnvironmentin interfaceUIContext- Parameters:
environment- the environment to set.
-
setFocusRequired
public void setFocusRequired(boolean b)
Sets whether a component needs to be given focus.- Specified by:
setFocusRequiredin interfaceUIContext- Parameters:
b- true if focus is required, false otherwise.- See Also:
UIContext.setFocussed(WComponent, UIContext)
-
setFocussed
public void setFocussed(WComponent component, UIContext uic)
Sets the component in this UIC which is to be the focus of the client browser cursor. The id of the component is used to find the focussed element in the rendered html. Since id could be different in different contexts the context of the component is also needed.- Specified by:
setFocussedin interfaceUIContext- Parameters:
component- - the component that sould be the cursor focus in the rendered UI.uic- - the context that the component exists in.
-
setFocussed
public void setFocussed(WComponent component)
Sets the component in this UIC which is to be the focus of the client browser cursor. The id of the component is used to find the focussed element in the rendered html.- Specified by:
setFocussedin interfaceUIContext- Parameters:
component- the component that sould be the cursor focus in the rendered UI.
-
setFwkAttribute
public void setFwkAttribute(String name, Object value)
Reserved for internal framework use. Sets a framework attribute.- Specified by:
setFwkAttributein interfaceUIContext- Parameters:
name- the attribute name.value- the attribute value.
-
setModel
public void setModel(WebComponent component, WebModel model)
Stores the extrinsic state information for the given component.
-
setUI
public void setUI(WComponent ui)
For use by internal framework code only. Sets the top level web component for this context.
-
getLocale
public Locale getLocale()
Retrieves the locale for this context.
-
setLocale
public void setLocale(Locale locale)
Sets the locale for this context.
-
getBacking
public UIContext getBacking()
- Returns:
- the backing context.
-
getRequestScratchMap
public Map<Object,Object> getRequestScratchMap(WComponent component)
Reserved for internal framework use. Get scratch map with request scope.- Specified by:
getRequestScratchMapin interfaceUIContext- Parameters:
component- the component to retrieve the scratch map for.- Returns:
- the scratch map with request scope
-
clearRequestScratchMap
public void clearRequestScratchMap(WComponent component)
Reserved for internal framework use. Clears the scratch map with request scope.- Specified by:
clearRequestScratchMapin interfaceUIContext- Parameters:
component- the component to clear the scratch map for.
-
clearRequestScratchMap
public void clearRequestScratchMap()
Reserved for internal framework use. Clears the scratch map with request scope.- Specified by:
clearRequestScratchMapin interfaceUIContext
-
getPrimaryUIContext
@Deprecated public static UIContext getPrimaryUIContext(UIContext uic)
Deprecated.A utility function to iterate to the primary (top most) context and return it.- Parameters:
uic- the UIContext to retrieve the primary context for.- Returns:
- the primary context for the given context.
-
-