如何使用Liferay中的Portlet名称获取Portlet ID? [英] How to get Portlet Id using the portlet name in Liferay?

查看:74
本文介绍了如何使用Liferay中的Portlet名称获取Portlet ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Portlet名称获得资源许可.

I have a requirement of getting resource permission using portlet name.

我将使用portlet的名称而不是ID.

I will have the name of the portlet not the Id.

Portlet的资源许可权名称是该Portlet的ID.我检查了Portlet表,它只有ID和其他信息. Portlet的其他属性将保存在哪里?

Resource Permission name for a portlet is that portlet's Id. I checked the Portlet table, it has only the Id and other info. Where will be the other attributes of portlet saved?.

有没有一种方法可以通过使用portlet的名称来获取portlet的ID.我有一个工作区来获取所有portlet并进行比较,但是如果我可以使用portlet的名称直接获取portlet的ID,那将会很有帮助.

Is there a way I can get portlet's Id by using portlet's name. I have a workaroud to get all portlets and compare, but if I can directly get portlet's Id using portlet's name it will be helpful.

这很紧急,如果有人知道请回复,将会很有帮助.

Its urgent, if anyone knows pls reply back, it will be of great help.

预先感谢

推荐答案

如果仔细查看如何根据Portlet名称生成Portlet ID,您将得到答案.

If you look closely as to how the Portlet Id is generated based on the Portlet Name, you would get the answer.

这是一个遵循的常量模式,因此如果您有名称,则可以像liferay一样构造Portlet Id. Liferay还借助Portlet名称来构造ID.

It is a constant pattern which is followed, so you can construct the Portlet Id like liferay does it if you have the name. Liferay also constructs the ID with the help of the portlet name.

portlet-id的模式:<portletname in xml>_WAR_<servlet context name i.e. the war file without any special characters such as the hyphen>

Pattern of portlet-id: <portletname in xml>_WAR_<servlet context name i.e. the war file without any special characters such as the hyphen>

例如: 如果您的Portlet名称是在portlet.xml中定义的MyWork,并且webapps文件夹中的生成文件(如果使用的是tomcat)是MyWork-portlet,那么结果ID将是MyWork_WAR_MyWorkportlet.

For example: If your portlet name is MyWork defined in portlet.xml and the generated file in the webapps folder (if you are using tomcat) is MyWork-portlet then the resultant Id will be MyWork_WAR_MyWorkportlet.

现在,如果您拥有liferay源代码,则可以查看

Now if you have liferay source code, you can look at PortletLocalServiceImpl's private _readPortletXML method.


如果要在特定页面上找到portlet(根据页面的friendly-url),则可以找到此
answer 有用.


If you want to find the portlets on a particular page (given the friendly-url of the page) then you may find this answer helpful.

这篇关于如何使用Liferay中的Portlet名称获取Portlet ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆