|
Home > Archive > WebSphere Portal Server > March 2004 > Passing Data or Sharing Variables between Page and Portlets in WebSphere Portal 5
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Passing Data or Sharing Variables between Page and Portlets in WebSphere Portal 5
|
|
|
| How does one pass data or share variables between page and portlets in
WebSphere Portal 5?
Specifically, I am looking to share a page-level variable instantiated
in a Theme with the portlets on the page through the Skin using
Control.jsp.
What I did was to create a String variable in the Head.jsp like this:
String selNodeTitle = "";
and then, in PlaceBar.jsp and PageBar.jsp I set that variable to the
Title of the currently selected node in the Navigation Model
(borrowing code from LayerContainer-V.jsp).
I know the value of the variable had been set because I am able to
write it out to the resulting page before calling ScreenRender.
However, when I try to use the variable in a JSP expression statement
(e.g. <%=selNodeTitle%> ) in Control.jsp, I get a Null Pointer
exception (I think - at least the portlets in the page fail to render
with the Skin.) Is this because variables in Control.jsp are somehow
scoped differently or namespace encoded relative to the portlet it's
attached to? If so, how do you share a page-level variable (e.g. set
in the Head) with portlets in the page?
Thanks
BS
| |
| Michael Harris 2004-03-22, 5:34 pm |
| You can't share variables between .jsp files unless they are included with
the @include directive. @include basically inserts the text of the included
file into the source file before the compile occurrs. Both .jsp files are
compiled into the same servlet.
The JSP files from a skin or a portlet are not included into the same
servlet so you can't reference scripting variables created in one from the
other.
For your solution, you need to store your object in a shared object such as
the request.
|
|
|
|
|