-
1. Get "GET" parameter for a portlet?
rraposa Apr 12, 2011 6:35 PM (in response to skau)It's not trivial to retrieve a GET parameter in a portlet. The logic is because the portlet is only a portion of a much larger portal page. At any rate, there is a way to retieve them using a PhaseListener. Have you seen this post:
-
2. Get "GET" parameter for a portlet?
trong.tran Apr 13, 2011 2:50 AM (in response to rraposa)You can also retrieve the value of the paramter in URL's query string from a portlet if and only it is a public render paramter and supported in the Portlet.
You could refer more detail about Public Render Paramters in the Portlet Spec 2.0
-
3. Get "GET" parameter for a portlet?
skau Apr 18, 2011 5:19 AM (in response to trong.tran)Hi Forum Member,
Thanks for your reply.
I thought the second succession sounded good and I tried to use a public render parameter.
I wrote in my portlet.xml
<portlet>
….
<supported-public-render-parameter>custID</supported-public-render-parameter>
</portlet>
<public-render-parameter>
<description>Apublic render parameter</description>
<identifier>custID</identifier>
<name>custID</name>
</public-render-parameter>
My URL looks like:
http://localhost:8080/…../portlet?custID=123456
Last but not least the java class:
Protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throwsIOException {
String param = (String) renderRequest.getAttribute(“custID”);
}
But the param is always null.
Anybody knows my failure?
I still useGateIN 3.1.0 GA
Cheers
Steffen
P.S.
I also tried to override the processAction Methode but these methode was never called.
-
4. Get "GET" parameter for a portlet?
vstorm83 Apr 18, 2011 5:37 AM (in response to skau)You can use render parameter or public render parameter, they will be used to render the portlet url --> user have to click on that url --> in render (or doView... ) method, you can use the request.getParameter (not getAttribute) method to get these parameters
-
5. Re: Get "GET" parameter for a portlet?
skau Apr 18, 2011 8:01 AM (in response to vstorm83)Hi Vu Viet Phuong,
thanks for your reply.
I changed the method call to request.getParameter("custID"); but the String is still null.
Cheers,
Steffen
-
6. Get "GET" parameter for a portlet?
rraposa Apr 18, 2011 8:02 AM (in response to skau)I think what Vu Viet is saying is that INSTEAD OF using a URL parameter, you can use a public render parameter. But you can NOT get a URL parameter by simply calling the method request.getParameter("") inside of a portlet - it's not going to work. There is no single method call in a GateIn portlet to retrieve a URL parameter.
Trong - are you sure your response is correct? I have not seen anything in the portlet spec about URL parameters needing to be public render parameters.
Steffen - please read this post closely: http://community.jboss.org/message/550397
-
7. Re: Get "GET" parameter for a portlet?
skau Apr 18, 2011 8:24 AM (in response to rraposa)Hi Rich,
Thanks for your help.
I read this post but I thought with GateIn 3.2 I could used a way without added a PhaseListener.
So I trie dthe way with the public render parameter.
I thought it meant that I built an URL with an UrlRewriteFilter and after it I read this parameter from request object in my doView method.
Rich do you mean the way I tried is not possible and the only soulution is to take the example with the PhaseListener?
Cheers;
Steffen
-
8. Re: Get "GET" parameter for a portlet?
rraposa Apr 18, 2011 8:50 AM (in response to skau)Steffen,
I have not done this myself before, so I'm not sure how to do it. Using a PhaseListener is the only way I have heard it done in a portlet. However, I have written code to retrieve a URL parameter in a JSF backing bean over the PortletBridge, but I'm not sure that is your situation.
Sorry I can't provide any example! I would be very interested in seeing the code if anyone out there has done this before.
I think in the future GateIn needs to provide a simple mechanism for retrieving URL parameters. I realize it is not part of the spec, but it can be done in other portals like Liferay and Websphere.
-Rich
-
9. Re: Get "GET" parameter for a portlet?
vstorm83 Apr 18, 2011 10:39 AM (in response to rraposa)Actually, I don't modify the portlet url "by hand" , I have written a simple test :
PortletURL renderURL = response.createRenderURL();
renderURL.setParameter("test", "testValue");
renderURL.toString(); --> put this to <a> html
another way to set the parameter to url is that you can use the ActionResponse.setRenderParameter() method
After click that URL ---> In the doView method, I call RenderRequest.getParameter() method --> and it works
@Steffen Kau : If you want I will send you that code, I hope this is what you need
-
10. Get "GET" parameter for a portlet?
skau Apr 19, 2011 4:22 AM (in response to vstorm83)Hi Vu Viet Phuong,
Thanks for your reply and your offer.
I am very interestin an example.
I think I should explain my current situation.
I need a page in a portal. This page only contains one portlet (the portlet I try to write). The URL of this page is
http://localhost:8080/portal/private/classic/Portlet.
My goal is that a user can write an URL (or bookmark this link or tell it a friend) like
http://localhost:8080/portal/private/classic/Portlet/BR1509 and a filter for URLRewriting change it to
http://localhost:8080/portal/private/classic/Portlet?custID=BR1509
I will resolve this problem with urlrewritefilter-3.2.0.
The next step should be that my portlet take this custID (GET-parameter) and looking for the product in my database.
After it the content for this product is shown in the portlet.
Cheers,
Steffen
P.S.
Is there any difference between to use the RenderResponse.getWrite methodfor writing html or use a separate jsp file for the contend view?
-
11. Get "GET" parameter for a portlet?
hoang_to Apr 20, 2011 12:57 AM (in response to skau)Let's put a break point in your method processAction to see if when you browse the page, the method is executed or not !
-
12. Get "GET" parameter for a portlet?
skau Apr 20, 2011 1:36 AM (in response to hoang_to)Hi Minh Hoang To,
Thanks for your reply,
I was wrong with this question. When i called the portlet i had only a Render-Request because I browsed the portlet page directly from the bookmark.
So i have to change my question in
how do I get a get-parameter in an render-request without any action-request?
Cheers Steffen
-
13. Get "GET" parameter for a portlet?
trong.tran Apr 21, 2011 3:07 AM (in response to rraposa)Rich Raposa wrote:
Trong - are you sure your response is correct? I have not seen anything in the portlet spec about URL parameters needing to be public render parameters.
Actually what i meant is just : In GateIn, the public render parameters are visible obviously in URL. Let's say we have a following render URL :
You will see that only public render paramters are visible from URL ( zip-id=newValues in the case ). And it can be retrieved from the portlet which supported the public render paramter.
Anyway, using of public render paramters seems not to fit in with Steffen Kau's need.
-
14. Re: Get "GET" parameter for a portlet?
skau Apr 21, 2011 3:40 AM (in response to skau)Hi forum members,
I got the solution from the exo forum.
For GateIn you can use the Util.getPortalRequestContext().getRequestParameter(“custID”) method
from the org.exoplatform.portal.webui.util.Util package.
Cheers and have a nice weekend,
Steffen.