• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Show details of story on a different page of portlet

 
Susan Mincey
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have spent most of the day trying to make this happen so maybe someone can spot my error(s). I have a JSR-168 with 2 portlets defined. The first portlet presents 3 short stories from the database on the Home page using view.jsp. The short stories have a Read More... link and hidden field with the story ID that should take the user to another page in our Portal (Vignette) where the second portlet resides. The second portlet uses details.jsp as the default jsp.

I have tried several methods of making that Read More ... link work and nothing is working.

I have used a form where the has a onClick="this.form.submit();" action which gets to my processAction just fine. From there I set a render parameter equal to the ID of the story and the doView picks this up (my logging proves that) but how do I define the page where the second portlet resides??? I have used the page id that Vignette generates but that doesn't work. And if I use details.jsp, the details page just refreshes into my Home page which is not the behavior I need.

I have also tried using a URL link with the story ID as a query parameter but that is not working.

Can anyone make suggestions? Has anyone done this before?

Thanks for any help or guidance
Susan
 
Susan Mincey
Greenhorn
Posts: 13
posted 6 years ago
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cameron McKenzie - if you are watching posts: I just watched your video which explained portlet-to-portlet communication (within the same web app or war) and that is exactly what I am trying to accomplish. I have modifed the processAction on portlet 1 to get a value from the form and put the value into the portletSession with Application Scope. I then switch to portlet 2 and modified the doView to grab that value.

This is not working. An outprint of the value shows "null". I have viewed other posts and forum and all say this is possible but I can't make it work. I also added the same code that was in the doView for Portlet 2 and put it into the jsp for that portlet. Still nothing. It looks like it should be easy but I am having difficulty. Can you provide any suggestions? Thanks
 
Neeraj Shidhaye
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how are you getting value in doView of portlet 2?

You will have to specify portlet session APPLICATION SCOPE, when you get value from session in doView of portlet 2.

portletSession.getAttribute("Key",PortletSEssion.APPLICATION_SCOPE);

hope that helps..

<Neeraj Sidhaye/>
http://ExtremePortal.blogspot.com

 
Susan Mincey
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Neeraj, I am using APPLICATION_SCOPE. It seems that when I add a parameter into session within the processAction, it does not work. I have read that you cannot access portlet session within processAction. It appears to work only within the doView. So I am abandoning this whole process and redesigning my application. Hopefully I can satisfy what the customer wants. Thanks again.
 
Costi Ciudatu
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I then switch to portlet 2 and modified the doView to grab that value.

How exactly do you "switch to portlet 2" from portlet1.processAction() ? ActionResponse.sendRedirect() or simply navigate to the page that contains portlet 2 ?

Separately, as far as I can see, it's mandatory that you construct the portlet 2 URL from inside portlet1. Perhaps your portal should provide an extended renderURL/actionURL tag that takes a portletId attribute or something. It's not enough to get to the second page, since you need to encode a portlet parameter.
 
Costi Ciudatu
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Susan Mincey wrote:I have read that you cannot access portlet session within processAction. It appears to work only within the doView.

Can you please provide a link that details this ? (I remember nothing about such a constraint)
 
Susan Mincey
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Costi,
I have done lots of googling regarding this and I know that JSR 286 will solve these issues but we cannot upgrade Vignette at this time to accomplish that. Here are some of the links I found:

Cameron McKinzie has a video showing interportlet communication (packaged in the same WAR which is exactly what I have) at this link:
http://technorati.com/videos/youtube.com%2Fwatch%3Fv%3DK7aMN1en_3U
However it shows the portletsession being set in the doView, not processAction

I am not using Icefaces but here is a link explaining the limits of setting portlet session in processAction with ICEfaces
http://www.icefaces.org/JForum/posts/list/6676.page

And finally here is someone who says that processAction will not set portletsession attributes which is what I think is happening to me. Maybe it's Vignette, maybe its me or maybe its just a shortfall in JSR168
http://www.liferay.com/web/guest/community/forums/-/message_boards/message/1880266;jsessionid=C45E407097183E33363C6310D56DF4BA

I have re-designed my app to use a database table to store the story id when a user clicks "Read more.." for a headline which will then display the details of that news story on ANOTHER PAGE of the portal where the second portlet resides. I am using a javascript redirect on a blank jsp page to accomplish this. The details.jsp page grabs the user name from our header, reads the database for the story id, displays the story and deletes the record from the database. It's still in testing and it's clumsy but it works so far.

I look forward to any comments from the viewing public!
 
Costi Ciudatu
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is one peculiar and dangerous way of sending a request parameter, unless _nothing else_ works...
I am using a javascript redirect on a blank jsp page to accomplish this.

Where is that javascript redirecting ? I mean, how do you construct that URL to redirect to ? Hardcoded some friendly (or unfriendly) URL as generated by the portal for your second page ?
 
Susan Mincey
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Costi,
Sorry I took so long to answer. Busy here! I am not sending any parameters to the redirect page. I am handling the parameters in processAction by writing to the database (user and the storyID they requested) and then the doView sends the user to my html page which contains only a Javascript redirect like this:
function move() {
window.location = 'https://my.company.com/portal/PORTALPAGEIDGOESHERE'.
}

That page contains code to get the user and go to the DB to retrieve the storyID they wanted to see. Once the story is displayed, the entry is deleted from the DB. It's kluggy, but it is working which is more than PortletSession was doing for me!

Hope that helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic