掲示板

Passing GET parameters to portlets

thumbnail
13年前 に Tim Lewis によって更新されました。

Passing GET parameters to portlets

New Member 投稿: 17 参加年月日: 10/07/01 最新の投稿
Hi All,
I have been pouring over the Web and Liferay, and cannot figure this out.

I have a page with a Web Content Display portlet on it, which contains a link to another page:

/player?movie="test.mp4"

I want to retrieve this parameter 'movie' on the 'player' page using its underlying velocity template. I will then insert this variable into the Flash code to make the video selected on the link appear in the player.

This seems as though it should be simple. Are my instincts wrong here?

Thanks,
Tim
thumbnail
13年前 に Tina Agrawal によって更新されました。

RE: Passing GET parameters to portlets

Expert 投稿: 297 参加年月日: 08/01/03 最新の投稿
I am not sure what you mean by using underlying velocity template.
But this is how you can get the movie parameter in your portlet class -



HttpServletRequest convertReq = PortalUtil.getHttpServletRequest(request);
HttpServletRequest originalReq = PortalUtil.getOriginalServletRequest(convertReq);
		
String movieName = originalReq.getParameter("movie");



Where request is of type RenderRequest.

Regards,
Tina
thumbnail
13年前 に Tim Lewis によって更新されました。

RE: Passing GET parameters to portlets

New Member 投稿: 17 参加年月日: 10/07/01 最新の投稿
Hi Tina,
I have a page called Videos, which has a Web Content Display portlet, which has a link with an href of '/player?movie=test.mp4'. I have a page called Player, which has a structure and VM template. I want to access the GET parameter 'movie' sent from the Videos page in this VM template.

Thanks,
Tim
thumbnail
13年前 に Tim Lewis によって更新されました。

RE: Passing GET parameters to portlets

New Member 投稿: 17 参加年月日: 10/07/01 最新の投稿
Anyone else able to comment? Liferay staff? I am not a portlet developer, so I need a way to send and receive HTTP parameters between Liferay pages. Use case is simple:

-- Page one has a link pointing to page two, sending it a parameter in the URL
-- Page two reads that parameter, and inserts it into the HTML for that page.

I am trying to do this using a Velocity template in page 2. Am I taking the wrong approach? Is the task harder than it looks?
thumbnail
13年前 に Ricardo J. Vandelay によって更新されました。

RE: Passing GET parameters to portlets

New Member 投稿: 17 参加年月日: 10/02/24 最新の投稿
Hi Tim.


#set($currentURL = "$getterUtil.getString($request.attributes.CURRENT_COMPLETE_URL)")
$httpUtil.getParameter($currentURL, "yourParameterNameHere")


Try it out.

You should check http://www.liferay.com/community/wiki/-/wiki/Main/CMS+Template+%28Velocity%29 for more info on the available velocity variables and also com.liferay.portal.velocity.VelocityVariables in the source code for more detail on the available methods on those variables.

Regards.
thumbnail
13年前 に Tim Lewis によって更新されました。

RE: Passing GET parameters to portlets

New Member 投稿: 17 参加年月日: 10/07/01 最新の投稿
Hi Ricardo,
I am grateful for your reply. Your solution worked for me. Before I read your post, I had retrieved CURRENT_COMPLETE_URL, but for the life of me, could not figure out a way to parse the URL for the parameters in the velocity template. Does the link you provided talk about $httpUtil? I don't remember seeing that variable listed for Velocity. I will review the material. I am finding it difficult to locate the info I need to keep going with this, so your help was vital.

I just dipped my toes into portal development earlier tonight; who knows, perhaps soon I will be creating portlets to solve these kinds of problems.

Along those lines, perhaps you could answer another question: I created a test portlet, and loaded it onto a page. I would like to pass it a GET parameter from another page, via a link. I tried simply typing into the URL bar something like /page2?video=test.mp4. I was unable to get the GET parameter to appear on page2. I am just not clear what Java method to call in the view.jsp to get it to show up. Is it simple, or is it a context/scope issue? My view.jsp contains something like this:


<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineobjects />

This is the <b>Test</b> portlet.
Request URI: &lt;%= request.getRequestURI() %&gt;
Hello <b>&lt;%= request.getParameter("video") %&gt;</b>! 




Thanks again, Ricardo. You made my evening!

Regards,
Tim
thumbnail
13年前 に Ricardo J. Vandelay によって更新されました。

RE: Passing GET parameters to portlets

New Member 投稿: 17 参加年月日: 10/02/24 最新の投稿
Hi Tim.

In that case it's a scope problem. You have two choices.

1. Your URL must be something like this:
http://yourdomain?p_p_id=THE_PORTLET_ID&_THE_PORTLET_ID_VARIABLENAME=value

2. Use Tina Agrawal's answer

Regards,
Ricardo
9年前 に Nwawel Nwawel A Iroume によって更新されました。

RE: Passing GET parameters to portlets

New Member 投稿: 9 参加年月日: 14/09/28 最新の投稿
It is about decades that i was looking for passing parameter between two portlet in different pages this work pretty fine!
thank agrawal emoticonemoticonemoticon
thumbnail
9年前 に Domingo Piña によって更新されました。

RE: Passing GET parameters to portlets

Junior Member 投稿: 28 参加年月日: 09/04/03 最新の投稿

    #set ( $convertReq = $portalUtil.getHttpServletRequest($renderRequest) )
    #set ( $originalReq = $portalUtil.getOriginalServletRequest($convertReq) )
    #set ( $catParam = $originalReq.getParameter("paramName") )