|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.plumtree.portaluiinfrastructure.tags.helper.TagState
public class TagState
This class manages variable storage and retrieval for tags. It allows you to get and set variables for various contexts (session, request, tag, etc...).
Field Summary | |
---|---|
static java.lang.String |
CACHE_LIB
The tag library used to store the cache map. |
static java.lang.String |
CACHE_MAPENTRY_NAME
Name of the cache map entry. |
protected static java.lang.String |
COMBINED_KEY_SEPARATOR
The separator between library and tag name in the combined key. |
static java.lang.String |
HTTP_REQUEST_DATA_KEY
This key is used to store HTTP request data collections on the session using the request as a key. |
protected IApplication |
m_Application
The HTTP Application. |
protected ATag |
m_CurrentTag
The current tag. |
protected XPHashtable |
m_HTTPRequestScopeData
The HTTP Request Data container. |
protected int |
m_nTagStackTop
The index into the top of the Tag Stack. |
protected ISessionManager |
m_PersistentSession
The persistent sub-session. |
protected XPHashtable |
m_PortletRequestScopeData
The Portlet Request Data container. |
protected ISessionManager |
m_Session
The sub-session. |
protected XPHashtable |
m_TagScopeData
The Tag Data container. |
protected XPArrayList |
m_TagStack
The Tag Stack. |
protected XPArrayList |
m_TagVarStack
The Tag Var Stack. |
protected boolean |
m_useParentTagScope
Whether to use parent tag scope or tag scope inside current tag when setting variables |
static java.lang.String |
SHARED_JS_COLLECTION
This key is used to store an http request level HTMLElementCollection that contains all of the shared javascript for the tags in the HTTP request. |
static java.lang.String |
SHARED_JS_COLLECTION_DISPLAYED
This key is used to store an http request level Boolean that marks whether or not the current shared javascript collection for this HTTP request has been retrieved for displayed or not. |
static java.lang.String |
SHARED_JS_VAR_LIST
This key is used to store an http request level list that stores whether or not a particular class of tags has been displayed on the page yet. |
static XPHashtable |
TEST_PORTLET_REQUEST_DATA
This static variable can be used to supply a pre-populated hashtable for the portlet request data. |
Constructor Summary | |
---|---|
TagState(IApplication _application,
ISessionManager _session,
ISessionManager _persistentSession,
XPHashtable _httpRequestData)
Creates a TagState object. |
Method Summary | |
---|---|
boolean |
AddCacheEntry(java.lang.String cacheKey,
java.lang.Object cacheValue,
Scope scope,
int duration)
Add a cached tag data entry Cache entries are stored in the same scope as the other tag variables, but cache entries are prefixed with a special string. |
protected void |
CheckValidVariableName(java.lang.String _strVariableName)
This method checks that the variable name does not contain any reserved characters ("."). |
void |
EnterTag(ATag _currentTag)
The tag container calls this method every time a new tag is displayed. |
void |
ExitTag()
The tag container calls this method when a tag is finished displaying. |
java.lang.Object |
GetAnyVariable(java.lang.String _strKey)
Gets a variable from memory from all scopes. |
IApplication |
GetApplication()
Return the Application for use in storing data on the HTTP Application. |
java.lang.Object |
GetCacheEntryData(java.lang.String cacheKey,
Scope scope)
Get tag data entry from cache |
static XPHashtable |
GetHTTPRequestData(AActivitySpace aSpace)
This method extracts the HTTP request data from the Activity Space. |
ISessionManager |
GetPersistentSubSession()
Returns the persistent subsession that can be used to store data on the HTTP Session for use across multiple login/logout cycles. |
static HTMLElementCollection |
GetSharedJavascriptCollection(AActivitySpace asOwner)
This method gets the shared JavaScript collection for this HTTP request, and initializes it if it has not been initialized yet. |
java.lang.Object |
GetSharedVariable(java.lang.String _strKey,
Scope _scope)
Gets a shared variable from memory in the appropriate scope. |
ISessionManager |
GetSubSession()
Returns the subsession that can be used to store data on the HTTP Session. |
protected java.lang.String |
GetTagName()
Get the name of the current tag. |
java.lang.Object |
GetVariable(java.lang.String _strKey,
Scope _scope)
Gets a variable from memory in the appropriate scope. |
protected TagCacheEntry |
InternalGetCacheEntry(java.lang.String cacheKey,
Scope scope)
Gets cache entry from the cache map |
protected XPHashtable |
InternalGetCacheMap(Scope scope)
Internal method to retrieve the Cache map object |
java.lang.Object |
InternalGetVariable(java.lang.String _strLibrary,
java.lang.String _strKey,
Scope _scope)
Helper method to get variables in memory. |
protected void |
InternalRemoveVariable(java.lang.String _strCombinedKey,
Scope _scope)
This method removes a variable from the underlying collection. |
protected void |
InternalSetVariable(java.lang.String _strLibrary,
java.lang.String _strKey,
java.lang.Object _oValue,
Scope _scope)
Helper method to set variables in memory. |
static void |
ResetPageRequestData(AActivitySpace _aSpace)
This method is called at the end of every HTTP request to reset the page request data. |
void |
ResetPortletRequestData()
The tag container calls this method to reset the portlet request data for each portlet on a page and to verify that the TagState is in the correct state after having finished displaying all of the tags in the current portlet request. |
static void |
SetSharedJavascriptCollectionAsDisplayed(AActivitySpace asOwner)
This method marks the shared JavaScript collection for this HTTP request as retrieved for display. |
void |
SetSharedVariable(java.lang.String _strKey,
java.lang.Object _oValue,
Scope _scope,
boolean bOwnerEditOnly)
Sets a variable in memory in the appropriate scope. |
void |
SetVariable(java.lang.String _strKey,
java.lang.Object _oValue,
Scope _scope)
Sets a variable in memory in the appropriate scope. |
void |
StoreInParentTagScope(boolean useParent)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CACHE_LIB
public static final java.lang.String CACHE_MAPENTRY_NAME
public static final java.lang.String SHARED_JS_VAR_LIST
public static final java.lang.String SHARED_JS_COLLECTION
public static final java.lang.String SHARED_JS_COLLECTION_DISPLAYED
protected static final java.lang.String COMBINED_KEY_SEPARATOR
public static final java.lang.String HTTP_REQUEST_DATA_KEY
protected XPArrayList m_TagStack
protected XPArrayList m_TagVarStack
protected int m_nTagStackTop
protected XPHashtable m_TagScopeData
protected XPHashtable m_PortletRequestScopeData
protected XPHashtable m_HTTPRequestScopeData
protected IApplication m_Application
protected ISessionManager m_Session
protected ISessionManager m_PersistentSession
protected ATag m_CurrentTag
protected boolean m_useParentTagScope
public static XPHashtable TEST_PORTLET_REQUEST_DATA
Constructor Detail |
---|
public TagState(IApplication _application, ISessionManager _session, ISessionManager _persistentSession, XPHashtable _httpRequestData)
_application
- The HTTP Application_session
- The sub-session_persistentSession
- The persistent sub-sessionMethod Detail |
---|
public void SetVariable(java.lang.String _strKey, java.lang.Object _oValue, Scope _scope)
ITagState
The scope determines who can see this variable and how long it stays in memory.
For instance, a variable stored in Tag Scope can only be seen by children of the current tag and will be removed from memory when the tag is finished.
A variable stored in Portlet Request Scope will be visible to all tags in the same portlet as the current tag, and will be removed from memory when the portlet is finished displaying. Tags in other portlets on the same page will not be able to see the variable.
Standard variables (as opposed to shared variables) can only be accessed by tags from the same tag library as the tag that originally stored the variable.
Note: Displaying an HTMLElement in a tag and then caching it so that another tag can add more HTML to the original tag later is not supported. HTMLElement trees can be generated and stored for later use, as long as they are self-contained trees and used in a read only way. It is safest to make clones of a cached HTMLElement tree before trying to display it again to make sure there are no threading problems.
SetVariable
in interface ITagState
ITagState.SetVariable(String, Object, Scope)
public void SetSharedVariable(java.lang.String _strKey, java.lang.Object _oValue, Scope _scope, boolean bOwnerEditOnly)
ITagState
The scope determines who can see this variable and how long it stays in memory.
For instance, a variable stored in Tag Scope can only be seen by children of the current tag and will be removed from memory when the tag is finished.
A variable stored in Portlet Request Scope will be visible to all tags in the same portlet as the current tag, and will be removed from memory when the portlet is finished displaying. Tags in other portlets on the same page will not be able to see the variable.
Shared variables (as opposed to standard variables) can be accessed by tags from any library. If bOwnerEditOnly is set to true when a shared variable is first stored, then any tag can read the variable, but only tags from the same library as the tag that originally stored the variable can edit it (and replace the value in memory).
Note: Displaying an HTMLElement in a tag and then caching it so that another tag can add more HTML to the original tag later is not supported. HTMLElement trees can be generated and stored for later use, as long as they are self-contained trees and used in a read only way. It is safest to make clones of a cached HTMLElement tree before trying to display it again to make sure there are no threading problems.
SetSharedVariable
in interface ITagState
bOwnerEditOnly
- True implies that only tags from
the same tag library should be able to store the value
for this tag. If this variable has already been saved,
then the original bOwnerEditOnly value will be retained
and this argument will be ignored.ITagState.SetSharedVariable(String, Object, Scope, boolean)
protected void CheckValidVariableName(java.lang.String _strVariableName)
String
- _strVariableName The variable name to be checked.
XPIllegalArgumentException
- if the variable name contains
illegal characters (".").protected void InternalSetVariable(java.lang.String _strLibrary, java.lang.String _strKey, java.lang.Object _oValue, Scope _scope)
_strLibrary
- The current library. May be null._strKey
- The key used to store the variable._oValue
- The variable._scope
- The scope used to store the variable.protected void InternalRemoveVariable(java.lang.String _strCombinedKey, Scope _scope)
_strCombinedKey
- The key used to access the variable._scope
- The scope used to store the variable. Assumed to be non-null.public java.lang.Object GetVariable(java.lang.String _strKey, Scope _scope)
ITagState
The scope determines who can see this variable and how long it stays in memory.
For instance, a variable can only be retrieved from Tag Scope if a tag that includes the current tag added the variable to Tag Scope.
A variable can only be retrieved from Portlet Request Scope if another tag in the portlet stored the variable in memory.
Standard variables (as opposed to shared variables) can only be accessed by tags from the same tag library as the tag that originally stored the variable.
Note: Retrieving an HTMLElement from memory that has already been displayed in another tag and then adding more HTML to the original tag is not supported. HTMLElement trees can be retrieved from memory and re-used, as long as they are not modified. The safest way to do this is to make a clone of the cached HTMLElement tree before trying to display it again to make sure there are no threading problems.
GetVariable
in interface ITagState
ITagState.GetVariable(String, Scope)
public java.lang.Object GetSharedVariable(java.lang.String _strKey, Scope _scope)
ITagState
The scope determines who can see this variable and how long it stays in memory.
For instance, a variable can only be retrieved from Tag Scope if a tag that includes the current tag added the variable to Tag Scope.
A variable can only be retrieved from Portlet Request Scope if another tag in the portlet stored the variable in memory.
Shared variables can be accessed by tags from any tag library (as opposed to standard variables, which can only be accessed by tags from the same tag library).
Note: Retrieving an HTMLElement from memory that has already been displayed in another tag and then adding more HTML to the original tag is not supported. HTMLElement trees can be retrieved from memory and re-used, as long as they are not modified. The safest way to do this is to make a clone of the cached HTMLElement tree before trying to display it again to make sure there are no threading problems.
GetSharedVariable
in interface ITagState
ITagState.GetSharedVariable(String, Scope)
public java.lang.Object GetAnyVariable(java.lang.String _strKey)
ITagState
The scope determines who can see this variable and how long it stays in memory.
For instance, a variable can only be retrieved from Tag Scope if a tag that includes the current tag added the variable to Tag Scope.
A variable can only be retrieved from Portlet Request Scope if another tag in the portlet stored the variable in memory.
Standard variables (as opposed to shared variables) can only be accessed by tags from the same tag library as the tag that originally stored the variable.
This method will first look for standard variables, and if not found will then look for shared variables.
Note: Retrieving an HTMLElement from memory that has already been displayed in another tag and then adding more HTML to the original tag is not supported. HTMLElement trees can be retrieved from memory and re-used, as long as they are not modified. The safest way to do this is to make a clone of the cached HTMLElement tree before trying to display it again to make sure there are no threading problems.
GetAnyVariable
in interface ITagState
com.plumtree.portaluiinfrastructure.tags.ITagState#GetAnyVariableFromAllScopes(String, Scope)
public java.lang.Object InternalGetVariable(java.lang.String _strLibrary, java.lang.String _strKey, Scope _scope)
_strLibrary
- The current library. May be null._strKey
- The key used to store the variable._scope
- The scope used to store the variable.
public boolean AddCacheEntry(java.lang.String cacheKey, java.lang.Object cacheValue, Scope scope, int duration)
AddCacheEntry
in interface ITagState
cacheKey
- cacheValue
- scope
- duration
- number of minutes the cache entry is valid
public java.lang.Object GetCacheEntryData(java.lang.String cacheKey, Scope scope)
GetCacheEntryData
in interface ITagState
cacheKey
- scope
- Scope.APPLICATION or Scope.Session
protected XPHashtable InternalGetCacheMap(Scope scope)
scope
-
protected TagCacheEntry InternalGetCacheEntry(java.lang.String cacheKey, Scope scope)
cacheKey
- scope
-
public IApplication GetApplication()
ITagState
Most developers should use the Get/SetVariable methods instead.
GetApplication
in interface ITagState
ITagState.GetApplication()
public ISessionManager GetSubSession()
ITagState
This SubSession is cleared of all data on logout.
Most developers should use the Get/SetVariable methods instead.
GetSubSession
in interface ITagState
ITagState.GetSubSession()
public ISessionManager GetPersistentSubSession()
ITagState
This SubSession is not cleared of its data on user logout, so be sure not to cache anything on this session that could be considered a security risk if it was leaked to another user.
Most developers should use the normal subsession (GetSubSession()) for HTTP Session data storage, and the Get/SetVariable methods instead.
GetPersistentSubSession
in interface ITagState
ITagState.GetPersistentSubSession()
public void EnterTag(ATag _currentTag)
public void ExitTag()
public static void ResetPageRequestData(AActivitySpace _aSpace)
ISessionManager
- the current session manager.public void ResetPortletRequestData()
public static XPHashtable GetHTTPRequestData(AActivitySpace aSpace)
aSpace
- The current AActivitySpace.
public static HTMLElementCollection GetSharedJavascriptCollection(AActivitySpace asOwner)
asOwner
- The current Activity Space.
public static void SetSharedJavascriptCollectionAsDisplayed(AActivitySpace asOwner)
asOwner
- The current Activity Space.
XPException
- if this method is called more than once in an HTTP request.protected java.lang.String GetTagName()
public void StoreInParentTagScope(boolean useParent)
StoreInParentTagScope
in interface ITagState
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |