Show TOC

Data Storing & Retrieving in the PortalLocate this document in the navigation structure

Use

The methods to store and retrieve data in the portal differ in the lifetime and accessibility. Lifetime is hard to guarantee in the portal. Lifetime can be very short - one request - or last the whole session. When using session keep in mind that the lifetime of a session is controlled by "external" events, like low resources on the server or time-out of the session, which will destroy the stored data in a session. The accessibility controls how "visible" the stored data is - can it be accessed by all users of the same component or only one user.

Storing data in the portal is generally not persistent. If you need persistent storing is needed we recommend a database.

In the Portal we have:

  • IPortalComponentContext

    The IPortalComponentContext defines a user specific view on a Portal Component.

  • IPortalComponentSession

    The IPortalComponentSession is the portal component's view on the servlet session. All objects stored in the Portal Component Session will be stored exclusively for the triple consisting of the Portal Component, the user id and the assigned scope. The lifetime of the shared session that is maintained by the portal environment should be determined by the portal setup only!

    The IPortalComponentSession is a "sub session" of request.getServletRequest().getSession(). It is unique per user and Portal Component.

  • ServletRequest

    ServletRequest is global for all Portal Components rendered in the same request (equals one Portal Object Model (POM) tree).

    Caution

    Be aware that even Portal Components on the same page are rendered in EP in different requests, because they are rendered in separate iFrames on the page! So you can't use the Servlet Request to transfer data between Portal Components! To use the ServletRequest makes only sense, if you combine two portal components in one request using the portal object model.

  • Node

    Node is a unique element in the Portal Object Model (POM) tree.

  • HTTP Session

    HTTP Session is global for all Portal Components in the same HTTP Session. You can exchange via HTTP Session data even on different pages.

The following table give you an overview of the different methods to store and retrieve data and the accessibility, persistence and lifetime. The table uses the variables:

IPortalComponentRequest: request

IPortalComponentSession: session = request.getComponentSession()

IPortalComponentContext: context = request.getComponentContext()

IPortalComponentProfile: profile = context.getProfile()

The table headers use following abbreviations:

S = Session specific

C = Component specific

N = Node specific

U = User specific

P = Persistent

Storing in/Methods

S

C

N

U

P

Lifetime

IPortalComponentContext

get: context.getValue()

put: context.putValue()

X

X

Refresh of component context

IPortalComponentProfile

Deprecated

get: profile.getValue()

put: profile.putValue()

scope for beans: application

X

X

IPortalComponentProfile

get: pro.getPropertyAttribute("key","val")

put: prof.setProperty("key","val")

X

X

X

IPortalComponentSession

get: session.getValue()

put: session.putValue()

Option: Declaration of a scope

public static short SCOPE_UNIQUE = 0;

public static short SCOPE_CONTEXT = 1;

public static short SCOPE_COMPONENT = 2;

Default: SCOPE_UNIQUE

Scope for beans: session

X

X

X

X

Maximum as long as the HTTP session

Servlet Request

get: request.getServletRequest().getAttribute()

put: request.getServletRequest().setAttribute()

scope for beans: request

X

X

Request

Node

get: request.getNode().getValue()

put: request.getNode().putValue()

X

X

X

X

HTTP Session

get: session.getHttpSession().getValue()

put: session.getHttpSession().putValue()

X

X

HTTP session

* Only if scope is set to SCOPE_UNIQUE