掲示板
Public Render Parameters
Hello,
I have a problem with the public render parameters and the action request.
I want to control the content of a portlet with a parameter (you give the db-table id with a get parameter and the content is loaded from the table). To accomplish this my first though was: Try to get the Action-URL and use it for this purpose. The problem with this Action-URL is: you need the specific Portlet ID so everything will be initiated.
I searched a bit and found the public render parameters.
Configurated everything, but now I only am able to display the parameters in my processAction and not when I render the content. And again, I seem to need the Portlet ID to toggle the Action.
Is there any way to get a parameter from my RenderRequest or toggle the Action without the Portlet ID?
I have a problem with the public render parameters and the action request.
I want to control the content of a portlet with a parameter (you give the db-table id with a get parameter and the content is loaded from the table). To accomplish this my first though was: Try to get the Action-URL and use it for this purpose. The problem with this Action-URL is: you need the specific Portlet ID so everything will be initiated.
I searched a bit and found the public render parameters.
Configurated everything, but now I only am able to display the parameters in my processAction and not when I render the content. And again, I seem to need the Portlet ID to toggle the Action.
Is there any way to get a parameter from my RenderRequest or toggle the Action without the Portlet ID?
12年前 に Tomas Polesovsky によって更新されました。
RE: Public Render Parameters
Liferay Master 投稿: 676 参加年月日: 09/02/13 最新の投稿
Hello Flo,
I'm not sure I fully understand. I try to explain basic use-cases and hope we'll meet somewhere
There can be many portlets on one portal page, therefore portlet parameters names in URL are encoded to be unique for each portlet (as they would mix).
If you want to display different content, use render phase (render/doView), not action phase (processAction). Action phase is just for changing state (update/delete D.
Public render parameters (and generally render parameters) are accessible to all portlets on the page in render phase. If you send parameters to the action phase, they are not copied over to render phase. If you want to publish them to render phase, you need to call response.setRenderParameter() method in processAction.
You can get more information in JSR-286 Portlet 2.0 spec.
-----
Your questions:
Is there any way to get a parameter from my RenderRequest
You can get portlet render parameters from RenderRequest. And you can get there also public render parameters.
or toggle the Action without the Portlet ID?
No. Portlet actions are always bound with specific portlet. Without portlet ID portal won't know which portlet use for triggering the action.
I'm not sure I fully understand. I try to explain basic use-cases and hope we'll meet somewhere
There can be many portlets on one portal page, therefore portlet parameters names in URL are encoded to be unique for each portlet (as they would mix).
If you want to display different content, use render phase (render/doView), not action phase (processAction). Action phase is just for changing state (update/delete D.
Public render parameters (and generally render parameters) are accessible to all portlets on the page in render phase. If you send parameters to the action phase, they are not copied over to render phase. If you want to publish them to render phase, you need to call response.setRenderParameter() method in processAction.
You can get more information in JSR-286 Portlet 2.0 spec.
-----
Your questions:
Is there any way to get a parameter from my RenderRequest
You can get portlet render parameters from RenderRequest. And you can get there also public render parameters.
or toggle the Action without the Portlet ID?
No. Portlet actions are always bound with specific portlet. Without portlet ID portal won't know which portlet use for triggering the action.
Public render parameters (and generally render parameters) are accessible to all portlets on the page in render phase. If you send parameters to the action phase, they are not copied over to render phase. If you want to publish them to render phase, you need to call response.setRenderParameter() method in processAction.
Hi Tomas,
exactly this I tried. I configured my Public Render Parameter like it is described in this Blog: http://www.liferay.com/de/web/steven.cao/blog/-/blogs/jsr-286-new-features-1-in-5-public-render-parameter
But when I try to get the Parameter in my jsp file with
<%=renderRequest.getParameter("public-render-param")%>
it doesn't work.When I tried to use the Parameter with an Action URL, the parameter could be used within my ProcessAction.
So there must be something I am doing wrong then .
12年前 に sarabjeet singh によって更新されました。
RE: Public Render Parameters
New Member 投稿: 15 参加年月日: 11/05/17 最新の投稿
Public render params are workin perfectly in my case.
I used eventing story board to generate all the related config files and actions with few clicks.
http://contrib.netbeans.org/portalpack/tutorials/eventing/EventingStoryBoardTutorial.html
Code for getting values of renderparameters
Portlet 1Publisher)
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
System.out.println("Within the portlet communication(processAction) !! ");
String name="JOHN RAMBO"
response.setRenderParameter("myid", name); //myid is the Public Render Parameter
}
Portlet 2(Subscriber):
@Override
public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException {
String names=request.getParameter("myid");
request.setAttribute("name",names);
System.out.println(names);
PortletRequestDispatcher dispatcher =getPortletContext().getRequestDispatcher("/WEB-INF/jsp/PortB_view.jsp");
dispatcher.include(request, response);
}
Hope it helps u
I used eventing story board to generate all the related config files and actions with few clicks.
http://contrib.netbeans.org/portalpack/tutorials/eventing/EventingStoryBoardTutorial.html
Code for getting values of renderparameters
Portlet 1Publisher)
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
System.out.println("Within the portlet communication(processAction) !! ");
String name="JOHN RAMBO"
response.setRenderParameter("myid", name); //myid is the Public Render Parameter
}
Portlet 2(Subscriber):
@Override
public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException {
String names=request.getParameter("myid");
request.setAttribute("name",names);
System.out.println(names);
PortletRequestDispatcher dispatcher =getPortletContext().getRequestDispatcher("/WEB-INF/jsp/PortB_view.jsp");
dispatcher.include(request, response);
}
Hope it helps u
12年前 に Tomas Polesovsky によって更新されました。
RE: Public Render Parameters
Liferay Master 投稿: 676 参加年月日: 09/02/13 最新の投稿
Could you please post snippets of your code?
Thanks
-- tom
Thanks
-- tom
Hey,
I'll do:
I added this node to my portlet.xml:
...and also added this to my <portlet> - node:
My Portlet Class looks like this:
finally in my JSP-File I just try to output my Parameter:
I try to call the portlet like:
http://localhost:8080/somePage?p_r_p_564233524_city_id=test
or
http://localhost:8080/somePage?city_id=test
If I call the page with <p:actionURL/> I get the result in my Process action.
Also I forgot to try <p:renderURL/> (which I did now) and it also works, but I have to give the Portlet-ID as Parameter and that I do not want.
I'll do:
I added this node to my portlet.xml:
<public-render-parameter xmlns:x="http://www.liferay.com/public-render-parameters">
<identifier>city_id</identifier>
<qname>x:city_id</qname>
</public-render-parameter>
...and also added this to my <portlet> - node:
<portlet>
//... auto generated stuff
<supported-public-render-parameter>city_id</supported-public-render-parameter>
</portlet>
My Portlet Class looks like this:
public class somePortlet extends DpPortlet {
@Override
public void processAction(ActionRequest request, ActionResponse response) throws PortletException,IOException {
System.out.println("city:");
System.out.println(ParamUtil.getString(request, "city_id"));
}
@Override
public void doView(RenderRequest request,RenderResponse response) throws PortletException,IOException {
response.setContentType("text/html");
System.out.println("city:");
System.out.println(ParamUtil.getString(request, "city_id"));
PortletRequestDispatcher dispatcher =
getPortletContext().getRequestDispatcher("/WEB-INF/jsp/view.jsp");
dispatcher.include(request, response);
}
}
finally in my JSP-File I just try to output my Parameter:
<%=renderRequest.getParameter("city_id")%>
I try to call the portlet like:
http://localhost:8080/somePage?p_r_p_564233524_city_id=test
or
http://localhost:8080/somePage?city_id=test
If I call the page with <p:actionURL/> I get the result in my Process action.
Also I forgot to try <p:renderURL/> (which I did now) and it also works, but I have to give the Portlet-ID as Parameter and that I do not want.
12年前 に Tomas Polesovsky によって更新されました。
RE: Public Render Parameters
Liferay Master 投稿: 676 参加年月日: 09/02/13 最新の投稿
Hey,
nice, so as I see it works.
For PRP you don't need to pass portlet-id parameter for render phase.
I'm quite surprised that http://localhost:8080/somePage?p_r_p_564233524_city_id=test doesn't work. Is the 564... param ok? Something like <p:renderURL><p:param name="city_id">value</p:param></p:renderURL> should show you the correct URL.
-- tom
nice, so as I see it works.
For PRP you don't need to pass portlet-id parameter for render phase.
I'm quite surprised that http://localhost:8080/somePage?p_r_p_564233524_city_id=test doesn't work. Is the 564... param ok? Something like <p:renderURL><p:param name="city_id">value</p:param></p:renderURL> should show you the correct URL.
-- tom
Hi,
That is what I did to get the PRP: I build up the Render (and also the Action) URL to take a look how the Parameters are Transformed.
In my link I need to have the p_p_id Parameter with a correct value, so the Parameters going to be recognized. But therefore I always need to know what ID my current Portlet Instance has...
I'm quite surprised that http://localhost:8080/somePage?p_r_p_564233524_city_id=test doesn't work. Is the 564... param ok? Something like <p:renderURL><p:param name="city_id">value</p:param></p:renderURL> should show you the correct URL.
That is what I did to get the PRP: I build up the Render (and also the Action) URL to take a look how the Parameters are Transformed.
In my link I need to have the p_p_id Parameter with a correct value, so the Parameters going to be recognized. But therefore I always need to know what ID my current Portlet Instance has...
12年前 に Tomas Polesovsky によって更新されました。
RE: Public Render Parameters
Liferay Master 投稿: 676 参加年月日: 09/02/13 最新の投稿
Can you generate the URL programmatically?
Maybe it would be helpful to implement Friendly URLs to your portlet (http://server/page/-/portlet/nice/url/city_id)
-- tom
Maybe it would be helpful to implement Friendly URLs to your portlet (http://server/page/-/portlet/nice/url/city_id)
-- tom
Hello,
thank you for the Tipp with the friendly URL, I think that is what I need!
I took a look into it and also stumbled over some problems there: Friendly URL Mapper
thank you for the Tipp with the friendly URL, I think that is what I need!
I took a look into it and also stumbled over some problems there: Friendly URL Mapper