Portlet 有一个编辑模式,这就是我们参数化它们的方式。
我的问题是,以编程方式在加载 portlet 时准确地对其进行参数化的最佳方法是什么。
例如:我想让 Liferay 加载具有特定 ID 的 portlet 的两个实例,一个使用 paramA
,第二个使用 paramB
。
Portlets have an EDIT mode, and this is the way we can parametrize them.
My question is what it the best way to parametrize a portlet exactly at the moment its loaded, programmatically.
For example: I want to get Liferay to load two instances of the portlet with a certain ID, one with paramA
, second with paramB
.
发布评论
评论(3)
要加载不同的参数(在 Liferay 中更名为“Portlet Preferences”),您可以使用 PortletPreferences 来存储和检索不同的参数,
factory 需要 2 个参数,
通过这个对象,您可以获取参数:
并且您可以存储值:
To load different parameters (better known in Liferay as "Portlet Preferences") you can use PortletPreferences to store and retrieve different parameters,
The factory takes 2 parameters,
With this object you can get parameters:
And you can store values:
“Liferay embed portlet”对我解释您的问题所要求的内容提供了很好的基本搜索(但我并不完全清楚)。
有了这个,我发现了类似 在您的 portlet 中嵌入 portlet< /a> 和
在 Web 内容中嵌入 Portlet 看起来很匹配。
如果不是我赞同brandizzi的评论:请给出高级问题(您需要以业务术语解决)而不是建议的解决方案(您需要技术细节,即使这对原始问题来说是一个糟糕的解决方案)
"Liferay embed portlets" gives a good basic search on what I interpret your question to ask for (but it's not fully clear to me).
With this I find hits like Embedding portlets in your portlet and
Embedding Portlets in Web Content that seem to match.
If it's not that I second brandizzi's comment: Please give the high level problem (that you need to solve in business terms) instead of the proposed solution (that you need the technical details for, even if it's a bad solution for the original problem)
您可以使用 url 参数。
我将描述两种方法。
1) 为每个 portlet 使用不同的参数,但您必须使用要查找的参数名称(每个 portlet 不同)来配置每个 portlet(portlet 首选项)。
用法示例: http://www.myserver.com/mypagewithportlets?param1=something1& param2=somethnig2
2) 使用以portlet命名空间为前缀的参数,但使用参数时需要知道portlet id(napespace是portlet id,前缀=后缀=_)
使用示例:http://www.myserver.com/mypagewithportlets?_name_WAR_myportlet_INSTANCE_xzy1_myparameter=something1&_name_WAR_myportlet_INSTANCE_syhs_myparameter=somethnig2
只是一个注释
p_request 实现 javax.portlet.PortletRequest
p_response 实现 javax.portlet.PortletResponse
You could use url parameters.
I'll describe two approaches.
1) Use different parameters for each portlet, but you have to configure each portlet (portlet preferences) with parameter name which to look for (different for each portlet).
usage example: http://www.myserver.com/mypagewithportlets?param1=something1¶m2=somethnig2
2) Use parameter prefixed with portlet namespace, but when using parameters you need to know portlet id's (napespace is portlet id with prefix=suffix=_)
usage example: http://www.myserver.com/mypagewithportlets?_name_WAR_myportlet_INSTANCE_xzy1_myparameter=something1&_name_WAR_myportlet_INSTANCE_syhs_myparameter=somethnig2
Just a note
p_request implements javax.portlet.PortletRequest
p_response implements javax.portlet.PortletResponse