Liferay portlet 可以获取参数吗?
我无法理解 CMS 中 portlet 的概念。
假设我编写了一个天气 portlet 来显示当前温度。我构建它,将其打包到战争中,然后在 Liferay 中部署战争。
现在我创建了一个页面,并且我想创建我编写的 portlet 的 2 个实例。我想显示西雅图和迈阿密的天气。
我可以这样做吗?如何向 portlet 传递一个参数来告诉它要显示哪个城市?
I am having trouble understanding the concept of portlets in a CMS.
Let's say I write a weather portlet to display current temperature. I build it, package it in a war, deploy the war in Liferay.
Now I created a page, and I want to create 2 instances of the portlet I wrote. I want to display the weather in Seattle and the weather in Miami.
Can I do this? How do I pass the portlet a parameter to tell it which city to display?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Portlet具有所谓的编辑模式。您可以实现编辑模式来显示表格来选择要显示哪个城市的温度。将其保存到 portlet 首选项中。当您以正常 (VIEW) 模式呈现 portlet 时,请查看城市的首选项。
Portlet has so-called EDIT-mode. You can implement EDIT mode to show the form to choose which city you want to show the temperature for. Save this to portlet preferences. And when you will render the portlet in normal(VIEW) mode, look at the preferences for the city.
另一个选项是 PortletConfig - 通常在 portlet.xml 中配置,类似于 Servlet init params。偏好可能是您最好的选择。
特别是如果您使用 Liferay,LR 的模型构建器基础设施将为您提供许多此类功能,包括以跨容器可移植性为代价的快速/廉价编辑。从好的方面来说,它将与 LR 的(有限的)RBAC 很好地集成,这在分布式内容创作环境中往往很重要
Another option is PortletConfig - which is generally configured in portlet.xml and is similar to Servlet init params. Preferences is probably your best bet.
If you're working in Liferay in particular, LR's model-builder infrastructure will get you much of this functionality including editing quick/cheap at the cost of cross-container portability. On the plus side it will integrate well with LR's (limited) RBAC which tends to be important in distributed content authoring environments