从 renderRequest 中的 OrignalParameterMap 检索公共渲染参数
我已使用用户友好的 URL 导航将呈现参数从一个 Portlet 传递到另一个 Portlet。
response.setRenderParameter("params", renderParams);
response.sendRedirect(response.encodeURL("/wps/myportal/Home/abcPortlet"), "params");
这里 Home
和 abcPortlet
是特定页面的用户友好页面名称。
在调试时,我发现 OriginalParameterMap
在其 URL 中包含渲染参数。
有人可以告诉我如何找回它吗?与往常一样,getter 方法无法检索该值。
I have passed a render parameter from one portlet to another using user friendly url navigation.
response.setRenderParameter("params", renderParams);
response.sendRedirect(response.encodeURL("/wps/myportal/Home/abcPortlet"), "params");
Here Home
and abcPortlet
are user friendly page names for specific pages.
While debugging I found that OriginalParameterMap
contains the render parameter in its URL.
Can someone tell me how to retrieve it? As usual getter methods are not able to retrieve that value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法将渲染参数从一个 portlet 传递到另一个 portlet。它必须是公共渲染参数(PRP)。设置 PRP 的方法与渲染参数的方法相同,但是两个 Portlet 都应该同意,它们都支持该 PRP。为此,您需要在两个 portlet 的
portlet.xml
文件中注册受支持的 PRP。请参阅此链接了解更多信息。这是规范坚持什么。想象这样一个场景:我们的门户页面上有来自不同供应商的多个 portlet。如果一个 portlet 可以从 URL 检索参数,即使它不是针对该 portlet,这也是一个安全问题。另一种方法(不推荐)是将
RenderRequest
键入HttpServletRequest
并从请求中获取参数。规范中没有提到PortletRequest
应该是HttpServletRequest
。所以最好不要这样做。 Portal 的未来实施可以改变这一点。第三种方法是使用 URL 生成 API 并构造具有针对 portlet 的参数的 URL。您可以参考下面的链接,其中有一些辅助类。这将简化您的工作。 高级 URL 生成帮助器类
最好的方法是使用 PRP。源 Portlet 和目标 Portlet 都是松散耦合的。
You cannot pass
render parameters
from one portlet to another. It has to be Pubic Render Parameter (PRP). The approach of setting PRP is same as that of render parameter, but both portlets should agree that, they support that PRP. For that you need to register the supported PRPs inportlet.xml
file of both the portlets. Please refer to this link for more info.This is what the specification insist. Imagine a scenario where in we have multiple portlets from various vendors on a portal page. It is a security concern if one portlet could retrieve the parameters from the URL even if it is not targeted to that portlet.Another approach (which is not recommended) is to type case the
RenderRequest
toHttpServletRequest
and get the parameter from request. It is not mentioned in the specification thatPortletRequest
should be aHttpServletRequest
. So it is better not to do that. Future implementation of Portal can change this.Third approach is to use the URL Generation APIs and construct the URL which has the parameters targeting the portlet. You can refer to the below link which has some helper classes. This will simplify your job. Advanced URL Generation Helper Classes
The best way is to use PRP. Both the source portlet and target portlet are loosely coupled.