Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

input parameter in portal theme

75 views
Skip to first unread message

moni...@in.ibm.com

unread,
Dec 5, 2007, 5:14:32 AM12/5/07
to
Hi ,<br />
<br />
I want to put one common input field in portal theme and then pass its value to portlet.<br />
<br />
I have already used Portlet:navigation URL to create a link to this portlet and it is working fine. here i m sending a parameter with url to the target portlet and it is recieved successfully at the target portlet.<br />
<p />
But now i want to take this parameter from user. but not able to do it.<br />
<br />
Please help me out.<br />
Thanks

RuneH

unread,
Dec 5, 2007, 5:24:50 AM12/5/07
to
Not totally sure here, but I do believe you need to create a servlet filter to make this possible if you are using JSR168 Portlets. I know that there should be a good article about this on Developerworks, but I'm not able to find it right now - instead I found this...which might lead you on the way<br />
<br />
<a href="http://www-128.ibm.com/developerworks/forums/">URL</a><a class="jive-link-external" href="http://www-1.ibm.com/support/docview.wss?uid=swg21288750">http://www-1.ibm.com/support/docview.wss?uid=swg21288750</a>[/URL]

Jim Barnes

unread,
Dec 5, 2007, 8:06:09 AM12/5/07
to
you will need to use the url generation tags or the url generation api to get this to work. I refer to the theme url generation tags. <br />
<br />
You do need to target the portlet specifically as the parameter would not be available otherwise to the portlet.<br />
<br />
If multiple portlets need access to this I would look at using some kind of singleton portlet service to share this information between the theme and the portlets<br />
<br />
IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0<br />
IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0<br />
<br />
The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM

gangadh...@aim.com

unread,
Dec 5, 2007, 11:08:37 PM12/5/07
to
Hi,<br />
<br />
I have done this type of scenario in my project to establish a communication between the search in the theme and to the search portlet.<br />
<br />
What I did was, I have set the parameter in request in the theme jsp by the following code<br />
<br />
&lt;% if(request.getParameter("sampleName")!=null)<br />
{ <br />
request.setAttribute("sarchKey",request.getParameter("sampleName"));<br />
}%&gt;<br />
<br />
And you can get the value in the portlet by the following code..<br />
<br />
//Getting HttpServletRequest from PortletUtils.getInternalRequest() method in <br />
//com.ibm.wps.pe.pc.std.core.PortletUtils(in wp.pe.rt.api.jar)<br />
<br />
PortletRequest portletRequest=(PortletRequest)request;<br />
HttpServletRequest httpReq=PortletUtils.getInternalRequest(portletRequest).getHttpServletRequest(); <br />
<br />
if(httpReq.getAttribute("sarchKey")!=null)<br />
{<br />
System.out.println("The value from theme::"+httpReq.getAttribute("sarchKey").toString());<br />
}<br />
<br />
Hope this helps you....<br />
<br />
Gangadhar

moni...@in.ibm.com

unread,
Dec 9, 2007, 4:36:25 AM12/9/07
to
Thx for Reply and help.<br />
<br />
I did the same assuggested by Gangadhar, and it was working fine.<br />
<br />
I can recieve parameters in my doview method of all portlets on that page.<br />
Gangadhar can u please explain how this code works, how portlet request converts into httpServletrequest.<br />
<br />
<b>I need ur help in one more thing. I want to add this attribute to session,</b> so it is available to all portlets, not to only those whose doview method is called.<br />
So i have decided to add it to session.<br />
<br />
Following ur code i have added this line in theme default.jsp<br />
<br />
request.getSession(true).setAttribute("sess", "20");<br />
<br />
and in doview of portlet<br />
<br />
PortletSession ps=request.getPortletSession(true);<br />
<br />
if(ps!=null){<br />
<br />
HttpSession hts=PortletUtils.getInternalSession(ps).getHttpSession();<br />
if(hts.getAttribute("sess")!=null){<br />
System.out.println("The value from session::"+hts.getAttribute("sess").toString());<br />
request.setAttribute("sess",hts.getAttribute("sess").toString() );<br />
}<br />
}<br />
<p />
<br />
i have made sure that <b>portlet session is true</b> in jsps.<br />
<br />
But i m not getting the attribute.<br />
<br />
Can u plz look into it..<br />
<br />
Thx in advance<br />
<br />
Monika

Jim Barnes

unread,
Dec 9, 2007, 6:49:31 AM12/9/07
to
To things to bear in mind casting the request object to the httpservletrequest object is not guaranteed to work on all jsr 168 implementations.<br />
<br />
The recommended way to share data among portlets in different wars is to use the following<br />
<a class="jive-link-external" href="http://www-128.ibm.com/developerworks/websphere/library/techarticles/0602_hepper/0602_hepper.html">http://www-128.ibm.com/developerworks/websphere/librar y/techarticles/0602_hepper/0602_hepper.html</a><br />
<br />
you can access in the theme as well, instead of accessing it with a portlet request use the session id, as all portlets and theme share the same session id, when you ask the portlet service for the data it uses the session id as part of the key, and that is how you can share it across the theme and portlets.<br />
<br />
The session objects will be scoped to an individual web app and items will not be shared across them.<br />

gangadh...@aim.com

unread,
Dec 10, 2007, 9:31:02 AM12/10/07
to
May be the way in which Jim has explained will work, I am just suggesting an alternative way using which we have implemented.<br />
<br />
In the JSP page when you say simply request , you will have httpserverltrequest.<br />
<br />
So , there are two possible ways.. I can suggest you, to my knowledge..<br />
<br />
1)Set it in ApplicationScope of the portlet in doView() saying that... request.getPortletSession().setAttribute(key, value, Session.APPLICATION_SCOPE);<br />
<br />
by this way.. you can get them in HttpSession... <br />
<br />
Now you can say in the page.. request.getSession().getAttribute(key);<br />
<br />
2)Set the value in your doView() once you get the attribute from Theme...<br />
<br />
like request.getPortletSession().setAttribute(key,value);<br />
<br />
Now in the page... say portletRequest.getPortletSession().getAttribute(key); . <br />
<br />
Dont simply say.. request.getSession()...<br />
<br />
This way... you should get it....<br />
<br />
Gangadhar

laila....@cgi.com

unread,
Jan 22, 2008, 2:24:09 PM1/22/08
to
how do you get your param from the input ?
do you use a javascript function ? ...

Jim Barnes

unread,
Jan 22, 2008, 9:54:37 PM1/22/08
to
THe only limitation is that portlets and the theme are not in the same web app
<br>

IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0<br>
IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0<br>
<br>

laila....@cgi.com

unread,
Jan 22, 2008, 10:40:59 PM1/22/08
to
sorry , didnt get your answer, is that mean that its impossible ?

moni...@in.ibm.com

unread,
Jan 23, 2008, 12:04:47 AM1/23/08
to
Hi,

This is the code i have used to send parameter from theme to one specified portlet.

For this we have to give unique name to portlet (="ibm.portal.registration")and its layoutnodes("ibm.comp.view"). It will target doview method of portlet. we can recieve the parameter through request.getParameter("CrNo").

&lt;portal-navigation:urlGeneration contentNode="ibm.portal.registration" layoutNode="ibm.comp.view"&gt;
&lt;portal-navigation:urlParam name="key" value="Delta" type="render" /&gt;
&lt;form name="f1" action="&lt;% wpsURL.write(out); %&gt;"&gt;
&lt;input type="text" name="CrNo" maxlength="8" size="8"&gt;

&lt;input type="submit"

&lt;/form&gt;
&lt;/portal-navigation:urlGeneration&gt;

Thanks
Monika

laila....@cgi.com

unread,
Jan 23, 2008, 12:34:57 AM1/23/08
to
Hi,
thanks for replying but the &lt;portal-navigation:urlParam name="key" value="Delta" type="render" /&gt;
Actually what i want is to send the value of an input in the theme to a portlet.
Thanks

moni...@in.ibm.com

unread,
Jan 23, 2008, 6:38:21 AM1/23/08
to
hi,
you can use the same code, i m sending one input text also
&lt;input type="text" name="CrNo" maxlength="8" size="8"&gt;

you can delete url paramaeter code &lt;portal-navigation:urlParam name="key" value="Delta" type="render" /&gt;

Thx

laila....@cgi.com

unread,
Jan 23, 2008, 10:07:11 AM1/23/08
to
Hi monika,
im still getting a null form my getParameter in the doview ..here is my code :
&lt;portal-navigation:urlGeneration contentNode="CC.CCTestPage"
layoutNode="CC.myPortlet"
portletWindowState="Maximized" accessControlCheck="NoCheck"&gt;

&lt;portal-navigation:urlParam name="myJSRParam" value="fromURLParam" type="render" /&gt;

&lt;form name="myForm" action="&lt;% wpsURL.write(out); %&gt;" &gt;
&lt;label for="directorySearchCriteria" &gt;Search for:&lt;/label&gt;
&lt;input id="directorySearchCriteria" name="directorySearchCriteria" type="text" /&gt;
<br>
&lt;input type="submit" value="GO" /&gt;

&lt;/form&gt;

&lt;/portal-navigation:urlGeneration&gt;


any ideas ?

0 new messages