Class UIContextImpl
- java.lang.Object
-
- com.github.bordertech.wcomponents.UIContextImpl
-
- All Implemented Interfaces:
UIContext
,Serializable
public class UIContextImpl extends Object implements UIContext
UIContextImpl - implementation ofUIContext
.- Since:
- 1.0.0
- Author:
- Martin Shevchenko
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description UIContextImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearRequestScratchMap()
Reserved for internal framework use.void
clearRequestScratchMap(WComponent component)
Reserved for internal framework use.void
clearScratchMap()
Reserved for internal framework use.void
clearScratchMap(WComponent component)
Reserved for internal framework use.void
doInvokeLaters()
Runs the runnables that were added usinginvokeLater(Runnable)
.Set<WebComponent>
getComponents()
long
getCreationTime()
Returns the creation time of this UIContext, which can be used to approximate the user session creation time.Environment
getEnvironment()
If an environment has been set, it is returned.WComponent
getFocussed()
String
getFocussedId()
Object
getFwkAttribute(String name)
Reserved for internal framework use.Set<String>
getFwkAttributeNames()
Reserved for internal framework use.Headers
getHeaders()
Locale
getLocale()
Retrieves the locale for this context.WebModel
getModel(WebComponent component)
Get the extrinsic state information for the given component.Map<Object,Object>
getRequestScratchMap(WComponent component)
Reserved for internal framework use.Map<Object,Object>
getScratchMap(WComponent component)
Reserved for internal framework use.WComponent
getUI()
void
invokeLater(UIContext uic, Runnable runnable)
Adds a runnable to the list of runnables to be invoked later.void
invokeLater(Runnable runnable)
Adds a runnable to the list of runnables to be invoked later.boolean
isDummyEnvironment()
boolean
isFocusRequired()
Indicates whether a component needs to be given focus.void
removeFwkAttribute(String name)
Reserved for internal framework use.void
removeModel(WebComponent component)
Removes the extrinsic state information for the given component.void
setEnvironment(Environment environment)
Explicitly set the environment.void
setFocusRequired(boolean focusRequired)
Sets whether a component needs to be given focus.void
setFocussed(WComponent component)
Sets the component in this UIC which is to be the focus of the client browser cursor.void
setFocussed(WComponent component, UIContext uic)
Sets the component in this UIC which is to be the focus of the client browser cursor.void
setFwkAttribute(String name, Object value)
Reserved for internal framework use.void
setLocale(Locale locale)
Sets the locale for this context.void
setModel(WebComponent component, WebModel model)
Stores the extrinsic state information for the given component.void
setUI(WComponent topUi)
For use by internal framework code only.
-
-
-
Method Detail
-
setUI
public void setUI(WComponent topUi)
For use by internal framework code only. Sets the top level web component for this context.
-
getUI
public WComponent getUI()
-
getModel
public WebModel getModel(WebComponent component)
Get the extrinsic state information for the given component.
-
setModel
public void setModel(WebComponent component, WebModel model)
Stores the extrinsic state information for the given component.
-
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:
removeModel
in interfaceUIContext
- Parameters:
component
- the component to remove the model for.
-
getComponents
public Set<WebComponent> getComponents()
- Specified by:
getComponents
in interfaceUIContext
- Returns:
- the set of WComponents that are storing a model.
-
setEnvironment
public void setEnvironment(Environment environment)
Explicitly set the environment.- Specified by:
setEnvironment
in interfaceUIContext
- Parameters:
environment
- the environment to set.
-
getEnvironment
public Environment getEnvironment()
If an environment has been set, it is returned. Otherwise a dummy environment is returned.- Specified by:
getEnvironment
in interfaceUIContext
- Returns:
- the current environment.
-
isDummyEnvironment
public boolean isDummyEnvironment()
- Specified by:
isDummyEnvironment
in interfaceUIContext
- Returns:
- true if the current environment is a 'dummy' environment.
-
invokeLater
public void invokeLater(Runnable runnable)
Adds a runnable to the list of runnables to be invoked later.- Specified by:
invokeLater
in 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.- Specified by:
invokeLater
in interfaceUIContext
- Parameters:
uic
- the UIContext to invoke the runnable in.runnable
- the runnable to add
-
doInvokeLaters
public void doInvokeLaters()
Runs the runnables that were added usinginvokeLater(Runnable)
.- Specified by:
doInvokeLaters
in interfaceUIContext
-
getFocussed
public WComponent getFocussed()
- Specified by:
getFocussed
in interfaceUIContext
- Returns:
- the focussed component for this UI.
-
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:
setFocussed
in interfaceUIContext
- Parameters:
component
- the component that sould be the cursor focus in the rendered UI.
-
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:
setFocussed
in interfaceUIContext
- Parameters:
component
- - the component that sould be the cursor focus in the rendered UI.uic
- - the context that the component exists in.
-
getFocussedId
public String getFocussedId()
- Specified by:
getFocussedId
in interfaceUIContext
- Returns:
- the unique id of the focused component for this UI.
-
setFocusRequired
public void setFocusRequired(boolean focusRequired)
Sets whether a component needs to be given focus.- Specified by:
setFocusRequired
in interfaceUIContext
- Parameters:
focusRequired
- true if focus is required, false otherwise.- See Also:
setFocussed(WComponent, UIContext)
-
isFocusRequired
public boolean isFocusRequired()
Indicates whether a component needs to be given focus.- Specified by:
isFocusRequired
in interfaceUIContext
- Returns:
- true if focus needs to be set.
- See Also:
setFocussed(WComponent, UIContext)
-
getFwkAttribute
public Object getFwkAttribute(String name)
Reserved for internal framework use. Retrieves a framework attribute.- Specified by:
getFwkAttribute
in interfaceUIContext
- Parameters:
name
- the attribute name.- Returns:
- the framework attribute with the given name.
-
setFwkAttribute
public void setFwkAttribute(String name, Object value)
Reserved for internal framework use. Sets a framework attribute.- Specified by:
setFwkAttribute
in interfaceUIContext
- Parameters:
name
- the attribute name.value
- the attribute value.
-
removeFwkAttribute
public void removeFwkAttribute(String name)
Reserved for internal framework use. Removes a framework attribute.- Specified by:
removeFwkAttribute
in interfaceUIContext
- Parameters:
name
- the attribute name.
-
getFwkAttributeNames
public Set<String> getFwkAttributeNames()
Reserved for internal framework use.- Specified by:
getFwkAttributeNames
in interfaceUIContext
- Returns:
- the names of all attributes bound to this context, or null if there are no attributes.
-
getScratchMap
public Map<Object,Object> getScratchMap(WComponent component)
Reserved for internal framework use. Retrieves a scratch area, where data can be temporarily stored. WComponents must not rely on data being available in the scratch area after each phase.- Specified by:
getScratchMap
in interfaceUIContext
- Parameters:
component
- the component to retrieve the scratch map for.- Returns:
- the scratch map for the given component.
-
clearScratchMap
public void clearScratchMap(WComponent component)
Reserved for internal framework use. Clears the scratch map for the given component.- Specified by:
clearScratchMap
in interfaceUIContext
- Parameters:
component
- the component to clear the scratch map for.
-
clearScratchMap
public void clearScratchMap()
Reserved for internal framework use. Clears the scratch map.- Specified by:
clearScratchMap
in interfaceUIContext
-
getRequestScratchMap
public Map<Object,Object> getRequestScratchMap(WComponent component)
Reserved for internal framework use. Get scratch map with request scope.- Specified by:
getRequestScratchMap
in 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:
clearRequestScratchMap
in 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:
clearRequestScratchMap
in interfaceUIContext
-
getCreationTime
public long getCreationTime()
Description copied from interface:UIContext
Returns the creation time of this UIContext, which can be used to approximate the user session creation time.- Specified by:
getCreationTime
in interfaceUIContext
- Returns:
- the creation time of this UIContext.
-
getHeaders
public Headers getHeaders()
- Specified by:
getHeaders
in interfaceUIContext
- Returns:
- the WHeaders instance for this context.
-
getLocale
public Locale getLocale()
Retrieves the locale for this context.
-
-