Oracle WebCenter Interaction Web Service Development Guide

     Previous Next  Open TOC in new window   View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Storing and Accessing Custom Data in Custom Adaptive Tags

To store custom data as member variables using a custom tag, use the SetStateVariable or SetStateSharedVariable methods. To retrieve it, use GetStateVariable or GetStateSharedVariable.

Standard variables (stored with SetStateVariable) can only be accessed by tags in the same library. Shared variables (stored with SetStateSharedVariable) can be accessed by tags from any library. To prevent tags from other libraries from editing a shared variable, set bOwnerEditOnly to true when the shared variable is stored (tags in other libraries will still be able to read the variable).
The Scope parameter determines who can see the data and how long it stays in memory. The following options are defined in the Scope class:
Application Scope Data is visible to all tags and all users, and is only removed when the application is restarted. Therefore, care should be used when storing data on the application to make sure it does not become cluttered with large amounts of data.
HTTP Request Scope Data will be visible to all tags in the same HTTP Request as the current tag, and is removed from memory when the HTTP Request is finished.
Session Scope Data is visible to all tags for the current user, and is cleared from memory when a user logs out and logs in again.
Persistent Session Scope Data is visible to all tags in the same HTTP session, and is only removed from memory when the browser is closed or the browser session times out. Note: Data is not cleared on user logout, so do not cache anything on this scope that could be considered a security risk if it was leaked to another user. Most tags should use Session Scope for HTTP Session data storage (as described above).
Portlet Request Scope Data is visible to all tags in the same portlet as the current tag, and is removed from memory when the portlet is finished displaying. Tags in other portlets on the same page will not be able to see the data.
Tag Scope Data can only be seen by children of the current tag and is removed from memory when the tag is finished. (For example, in the following tags: <pt:atag><pt:btag/></pt:atag><pt:ctag/>, data stored in Tag Scope by "atag" would be visible to "btag" but not to "ctag.")
If data is stored directly in the tag in member variables (not recommended), override the ReleaseTag method to release the data stored on the tag.
/** 
* @see com.plumtree.portaluiinfrastructure.tags.ATag#ReleaseTag() 
*/ 
public void ReleaseTag() 
{ 
// Release all member variables. 
m_strPreviousRequestURL = null; 
}
Note: Displaying an HTMLElement in a tag and caching it so another tag can add more HTML 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 clone a cached HTMLElement tree before trying to display it again to make sure there are no threading problems.
Note: It is a best practice not to use static fields for data storage in tags. Each tag instance is guaranteed to be accessed by only a single thread at a time, but there may be multiple threads accessing different instances of the same tag class at the same time, either from the same user or a different user. This means that any static fields must be accessed using synchronized methods. Since there can be multiple instances of the same tag running at the same time, state variables set in shared scopes (Session, Persistent Session and Application) could change values during the execution of a single tag.

  Back to Top      Previous Next