Skip to main content

developerWorks >  WebSphere  >  Forums  >  Portal and Portlet Development  >  developerWorks

GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1    Point your RSS reader here for a feed of the latest messages in this thread


Tags for this thread: 

     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
This question is not answered.

Permlink Replies: 15 - Pages: 2 [ 1 2 | Next ] - Last Post: Nov 2, 2009 5:16 AM Last Post By: PravinKumar
mark_polly

Posts: 15
Registered: Jun 22, 2005 02:43:36 PM
GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Mar 25, 2009 06:01:12 PM
 
Click to report abuse...   Click to reply to this thread Reply
Using Portal 6.1.01. I'm using the url generation discussed in http://www-01.ibm.com/support/docview.wss?rs=688&uid=swg21265900. The generation code is directly from wp.l2.urlhelper.jar attached to that document.

I'm in the LoginUserAuth class in doPostLogin, so my user has authenticated. I am using the below code to generate a url to a specific page (authenticated) within portal and portlet. I'm trying to pass parameters from LoginUserAuth to the portlet so I can use them in the render phase. Here is the snippet of code:
ObjectID pageoid = IdentificationHelper.getObjectID(REDIRECT_PAGE_OID);
ObjectID portletoid = IdentificationHelper.getObjectID(REDIRECT_PORTLET_OID);
targetURLStr = OffLineURLHelper.generateUrl(pageoid, portletoid, map, serverContext, true);
runData.setRedirectURL(targetURLStr);
return;

The OIDs come directly from the xmlaccess script, so I know they are both correct. The map contains just one value that needs to be passed to the portlet.

When this runs, my user is redirected to the correct page in Portal and the portlet displays on the page. However, no parameters appear in the render phase according to the code below.

In the portlet code, I do the following:
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
log.debug("Process the view");
Enumeration enummer = request.getParameterNames();
while(enummer.hasMoreElements()){
String parmName = (String) enummer.nextElement();
log.debug("Render param = " + parmName);
}
....
My log shows that I got to the render phase OK, but there are no parameter names showing up.

Any suggestions for what could be wrong? Is it possible to pass render parameters from the offline url generation while in LoginUserAuth?
PravinKumar

Posts: 22
Registered: Aug 06, 2007 11:33:02 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Mar 26, 2009 02:02:00 AM   in response to: mark_polly in response to: mark_polly's post
 
Click to report abuse...   Click to reply to this thread Reply
If your url is generated something like this

http://localhost:10038/wps/portal/samplepage?userid=pravin&str=pravin

then try the following code snippet it will work out.
public void doView(RenderRequest arg0, RenderResponse arg1)
throws PortletException, IOException {
System.out.println("Inside " + getClass() + " doView()");
HttpServletRequest servletRequest = (HttpServletRequest) arg0;
if (servletRequest.getQueryString() != null)
{
String queryString = servletRequest.getQueryString();
System.out.println("queryString >>>>>" + queryString);
}
}

Thanks
Praveen
mark_polly

Posts: 15
Registered: Jun 22, 2005 02:43:36 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Mar 26, 2009 12:49:41 PM   in response to: PravinKumar in response to: PravinKumar's post
 
Click to report abuse...   Click to reply to this thread Reply
Sorry, but, in a standard portlet, you can't access the parameters of a url in that fashion.
mark_polly

Posts: 15
Registered: Jun 22, 2005 02:43:36 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Mar 26, 2009 12:59:25 PM   in response to: mark_polly in response to: mark_polly's post
 
Click to report abuse...   Click to reply to this thread Reply
Update, I wasn't getting anywhere trying to get the render parameters, so I decided to use another form of the generateURL method in the OffLineURLHelper to get into the action phase of the view mode. Here is the call:

targetURLStr = OffLineURLHelper.generateUrl(PAGE_UNIQUENAME, PORTLET_UNIQUENAME, "view", map, serverContext, true, PortletType.StandardPortletType);

The resulting url is: http://my61portal.perficient.com:10040/wps/myportal/!ut/p/c4/04_SB8K8xLLM9MSSzPy8xBz9CP0os3hzf28zDw8LA0t3zxBDA0-DYM9gb9NAQwMjU_1I_ShjJHk_PwOQvFdQkJuFgYGBmX5EWWZquX4IyNzC0tSiyuKSosy8dP3IpJzEDBBWy4svSExPtS3OAgG1AggvGwyAhkfiNTw8MRnkTP2C7Mjc-FxHRQC5NMWk/

In this case, I still reach the correct page, but I get the following error in the log and the action phase is not called:
WPActionPhase W com.ibm.wps.engine.phases.WPActionPhase processPortlets EJPEI0170E: Cannot execute the received action com.ibm.wps.engine.commands.StandardActionDispatcher@271a271a due to a security violation. The action URL needs to contain an action ID.

Does anybody have any ideas about the action ID or the OffLineURLHelper class?
PravinKumar

Posts: 22
Registered: Aug 06, 2007 11:33:02 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Mar 30, 2009 07:20:26 AM   in response to: mark_polly in response to: mark_polly's post
 
Click to report abuse...   Click to reply to this thread Reply
The code snippet given is for a standard portlet itself. I am getting the values from the url.
Pls refer it once.
mark_polly

Posts: 15
Registered: Jun 22, 2005 02:43:36 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Mar 30, 2009 09:16:36 AM   in response to: PravinKumar in response to: PravinKumar's post
 
Click to report abuse...   Click to reply to this thread Reply
Did you try your suggestion on Portal 6.1 and a JSR 168 portlet? Here is the result of that.
Here is the doView code:
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
//Test code from developer works
HttpServletRequest servletRequest = (HttpServletRequest) request;
log.debug("Got the servletRequest");
if (servletRequest.getQueryString() != null)
{
String queryString = servletRequest.getQueryString();
log.debug("queryString >>>>>" + queryString);
}else log.debug("queryString >>>>> is null");
....

And the results:
(doView) - Got the servletRequest
(doView) - queryString >>>>> is null

According to the JSR 168/286 spec (PLT.19.3.8): On the other hand, the portlet does not have direct access to the path and query information of the client request as it is one component rendered on the page.
PravinKumar

Posts: 22
Registered: Aug 06, 2007 11:33:02 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Mar 31, 2009 01:04:14 AM   in response to: mark_polly in response to: mark_polly's post
 
Click to report abuse...   Click to reply to this thread Reply
Yes the query string is not coming in Portal v 6.1 whereas its coming in 6.0.
hemanth3698

Posts: 3
Registered: Apr 11, 2009 06:15:28 AM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Apr 11, 2009 06:19:31 AM   in response to: mark_polly in response to: mark_polly's post
 
Click to report abuse...   Click to reply to this thread Reply
Hi Mark,

I am facing the same issue in WP6.1. I am trying to retrieve query parameters from request but no luck.

have you managed to resolve this??

how to get HttpServletRequest in JSR168 portlets in WP6.1?

Thanks in Advance,
Hemanth.

mark_polly

Posts: 15
Registered: Jun 22, 2005 02:43:36 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Apr 11, 2009 10:11:58 AM   in response to: hemanth3698 in response to: hemanth3698's post
 
Click to report abuse...   Click to reply to this thread Reply
Sorry, I did not find a solution to this.
hemanth3698

Posts: 3
Registered: Apr 11, 2009 06:15:28 AM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Apr 11, 2009 01:29:27 PM   in response to: mark_polly in response to: mark_polly's post
 
Click to report abuse...   Click to reply to this thread Reply
Mark,

please let me know if there is any alternative to resolve this problem in 6.1.

my url(query string) looks something similar to this:

http://localhost:10038/wps/portal/samplepage?userid=pravin&str=pravin

Thanks in advance,
Hemanth

Stefan_Schmitt

Posts: 152
Registered: Sep 10, 2007 03:07:46 AM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Apr 12, 2009 09:49:35 AM   in response to: hemanth3698 in response to: hemanth3698's post
 
Click to report abuse...   Click to reply to this thread Reply
Two things to remark

Because the first generated URL is targeting to a unprotected area, but the authentication had been finished already Security does force a logout. This logout does stop the parameters for the JSR168 Portlet been added to the State of the current executed request.

The 2. problem which occurs (if you send it to a protected URL, may be caused by the Code made available in the technote. The error does show that an action is send to a portlet (what you expect) but Portal does expect in such case an action ID to track the action and prevent double execution.
hemanth3698

Posts: 3
Registered: Apr 11, 2009 06:15:28 AM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Apr 12, 2009 06:37:39 PM   in response to: Stefan_Schmitt in response to: Stefan_Schmitt's post
 
Click to report abuse...   Click to reply to this thread Reply
Hi Stefan,

Thanks for your reply. i can see this url (http://localhost:10038/wps/portal/searchItems?itemId=vapp&location=germany) when i hover my mouse on a link in my source portlet. both are jsr168 portlets.

when i click this, i could see the destination portlet displaying all the search items irrespective of item id and location as these two are coming as null values.

1. I don't this my destination portlet is an unprotected area neither it is forcing logoff.

2. i could see the parameters if i use wiring but can't get parameters when i use query string url.

how can i see the values?? please let me know how to get HttpServletRequest in portal 6.1 (JSR168 portlets).

Appreciate your help in this regard,
Hemanth.
mark_polly

Posts: 15
Registered: Jun 22, 2005 02:43:36 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in
Posted: Apr 13, 2009 03:54:03 PM   in response to: hemanth3698 in response to: hemanth3698's post
 
Click to report abuse...   Click to reply to this thread Reply
You cannot get query string parameters in JSR 168 portlets - the jsr spec doesn't allow portlets to get the query string.

Here are a couple of thoughts.
1. If you are trying to send data from one portlet to another, the way to do that is via wiring, not the query string. It sounds like you have that working somewhat. You will need to set up WSDL files in both portlets - the source will publish your id and location values, while the target portlet will consume them.

2. If you move up to JSR286 portlets, you can set public render parameters in the source portlet and then grab those render parameters in the target portlet.

3. If you are trying to pass parameters from outside of portal (like in a servlet, for example) and you want to target the parameters to a specific portlet, you can use Portal's URI Resolver service. The following article explains it pretty well, but you will have to modify it to target just one portlet. http://www.ibm.com/developerworks/websphere/library/techarticles/0710_koeth/0710_koeth.html
NNitin

Posts: 1
Registered: Oct 09, 2009 07:16:36 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Oct 09, 2009 07:28:52 PM   in response to: mark_polly in response to: mark_polly's post
 
Click to report abuse...   Click to reply to this thread Reply
Hi Mark,

I have the similar requirement as you mentioned below.
My requirement is :

I have a servlet with an HyperLink and i am using the OfflineURLGenerator.generateUrlString(page_name,portlet_name,null,serverContext,true);
within the generateUrlString method i have added the setTarget method by setting the target as PORTLET_ACTION and portletname as arguments.

So ultimately i could generate the targeturl and i can see the target page and portlet, but it is not calling the processAction method.

url : http://localhost:10040/wps/myportal/testvp/!ut/p/c4/04_SB8K8xLLM9MSSzPy8xBz9CP0os3gDQwtPXyNjE0P_sABXA08TZ283J-8gQ39nI_1IPPIWpqZA-Ui88uGJySCb9Auy03wBaGtRHA!!/

It gives me the below error:

10/9/09 15:59:12:310 PDT 00000037 WPActionPhase W com.ibm.wps.engine.phases.WPActionPhase processPortlets EJPEI0170E: Cannot execute the received action com.ibm.wps.engine.commands.StandardActionDispatcher@a8b0a8b due to a security violation. The action URL needs to contain an action ID.

Can you please help me out on this. i am in great urgent.

Regards,
NNitin.

gigipaul3

Posts: 55
Registered: Sep 05, 2007 04:32:46 PM
Re: GenerateURL within LoginAuthUser and passing parameters to a portlet in 6.1
Posted: Oct 30, 2009 03:37:34 PM   in response to: hemanth3698 in response to: hemanth3698's post
 
Click to report abuse...   Click to reply to this thread Reply
Passing parameter to a portlet: Were you able to resolve this? I Have a similar requirement like this. Any help is highly Appreciated.
Thanks
Gigi
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums