Interface UIContext
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
AbstractContainerHelper.UIContextWrap
,UIContextDelegate
,UIContextImpl
,WRepeater.SubUIContext
public interface UIContext extends Serializable
The state information for a WebComponent tree (a UI) is stored in a UIContext. The reason for this is to minimize the size of the footprint in the session. A UI can be shared between multiple sessions but there is only one UIContext per session. This is a form of the flyweight pattern.- Since:
- 1.0.0
- Author:
- Martin Shevchenko
-
-
Method Summary
All Methods Instance Methods Abstract 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
getComponents()
long
getCreationTime()
Returns the creation time of this UIContext, which can be used to approximate the user session creation time.Environment
getEnvironment()
If we've got an environment, return it.WComponent
getFocussed()
String
getFocussedId()
Object
getFwkAttribute(String name)
Reserved for internal framework use.Set
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
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 against the given UIContext.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 sets 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 ui)
For use by internal framework code only.
-
-
-
Method Detail
-
getUI
WComponent getUI()
- Returns:
- the top level web component for which is context applies.
-
setUI
void setUI(WComponent ui)
For use by internal framework code only. Sets the top level web component for this context.- Parameters:
ui
- the top level web component for this context.
-
getModel
WebModel getModel(WebComponent component)
Get the extrinsic state information for the given component.- Parameters:
component
- the component to get the model for.- Returns:
- the component's model.
-
setModel
void setModel(WebComponent component, WebModel model)
Stores the extrinsic state information for the given component.- Parameters:
component
- the component to set the model for.model
- the model to set.
-
removeModel
void removeModel(WebComponent component)
Removes the extrinsic state information for the given component. Note that this is not recursive for the children.- Parameters:
component
- the component to remove the model for.
-
getComponents
Set getComponents()
- Returns:
- the set of WComponents that are storing a model.
-
setEnvironment
void setEnvironment(Environment environment)
Explicitly sets the environment.- Parameters:
environment
- the environment to set.
-
getEnvironment
Environment getEnvironment()
If we've got an environment, return it. Otherwise return a dummy environment.- Returns:
- the current environment.
-
isDummyEnvironment
boolean isDummyEnvironment()
- Returns:
- true if the current environment is a 'dummy' environment.
-
invokeLater
void invokeLater(Runnable runnable)
Adds a runnable to the list of runnables to be invoked later. The runnable will be invoked against this UIContext.- Parameters:
runnable
- the runnable to add
-
invokeLater
void invokeLater(UIContext uic, Runnable runnable)
Adds a runnable to the list of runnables to be invoked later against the given UIContext.- Parameters:
uic
- the context to run the runnable in.runnable
- the runnable to add
-
doInvokeLaters
void doInvokeLaters()
Runs the runnables that were added usinginvokeLater(Runnable)
.
-
setFocussed
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.- Parameters:
component
- the component that sould be the cursor focus in the rendered UI.
-
setFocussed
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.- Parameters:
component
- - the component that sould be the cursor focus in the rendered UI.uic
- - the context that the component exists in.
-
getFocussedId
String getFocussedId()
- Returns:
- the unique id of the focussed component for this UI.
-
getFocussed
WComponent getFocussed()
- Returns:
- the focussed component for this UI.
-
setFocusRequired
void setFocusRequired(boolean focusRequired)
Sets whether a component needs to be given focus.- Parameters:
focusRequired
- true if focus is required, false otherwise.- See Also:
setFocussed(WComponent, UIContext)
-
isFocusRequired
boolean isFocusRequired()
Indicates whether a component needs to be given focus.- Returns:
- true if focus needs to be set.
- See Also:
setFocussed(WComponent, UIContext)
-
getFwkAttribute
Object getFwkAttribute(String name)
Reserved for internal framework use. Retrieves a framework attribute.- Parameters:
name
- the attribute name.- Returns:
- the framework attribute with the given name.
-
setFwkAttribute
void setFwkAttribute(String name, Object value)
Reserved for internal framework use. Sets a framework attribute.- Parameters:
name
- the attribute name.value
- the attribute value.
-
removeFwkAttribute
void removeFwkAttribute(String name)
Reserved for internal framework use. Removes a framework attribute.- Parameters:
name
- the attribute name.
-
getFwkAttributeNames
Set getFwkAttributeNames()
Reserved for internal framework use.- Returns:
- the names of all attributes bound to this context.
-
getScratchMap
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.- Parameters:
component
- the component to retrieve the scratch map for.- Returns:
- the scratch map with phase scope for the given component.
-
clearScratchMap
void clearScratchMap(WComponent component)
Reserved for internal framework use. Clears the scratch map with phase scope for the given component.- Parameters:
component
- the component to clear the scratch map for.
-
clearScratchMap
void clearScratchMap()
Reserved for internal framework use. Clears the scratch map with phase scope.
-
getRequestScratchMap
Map<Object,Object> getRequestScratchMap(WComponent component)
Reserved for internal framework use. Get scratch map with request scope.- Parameters:
component
- the component to retrieve the scratch map for.- Returns:
- the scratch map with request scope
-
clearRequestScratchMap
void clearRequestScratchMap(WComponent component)
Reserved for internal framework use. Clears the scratch map with request scope.- Parameters:
component
- the component to clear the scratch map for.
-
clearRequestScratchMap
void clearRequestScratchMap()
Reserved for internal framework use. Clears the scratch map with request scope.
-
getCreationTime
long getCreationTime()
Returns the creation time of this UIContext, which can be used to approximate the user session creation time.- Returns:
- the creation time of this UIContext.
-
getHeaders
Headers getHeaders()
- Returns:
- the headers instance for this UIContext.
-
getLocale
Locale getLocale()
Retrieves the locale for this context.- Returns:
- the Locale for this context, or null if no locale has been set.
-
setLocale
void setLocale(Locale locale)
Sets the locale for this context.- Parameters:
locale
- the Locale to set, or null for the default locale.
-
-