I have a requirement of getting resource permission using portlet name.
I will have the name of the portlet not the Id.
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?.
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.
Thanks in Advance
Liferay also constructs the ID with the help of the portlet name. 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 .
The Configuration Files are stored in the docroot/WEB-INF folder. Files stored here include the standard JSR-286 portlet configuration file portlet. xml , as well as three optional Liferay-specific configuration files.
Namespacing ensures that a given portlet's name is uniquely associated with elements in request parameters it sends to the portal. This prevents name conflicts with other elements on the portal page and with elements from other portlets on the page. Namespacing your portlet elements is easy.
Web apps in Liferay DXP are called portlets. Like many web apps, portlets process requests and generate responses. In the response, the portlet returns content (e.g. HTML, XHTML) for display in browsers.
If you look closely as to how the Portlet Id is generated based on the Portlet Name, you would get the answer.
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.
Pattern of portlet-id: <portletname in xml>_WAR_<servlet context name i.e. the war file without any special characters such as the hyphen>
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
.
Now if you have liferay source code, you can look at PortletLocalServiceImpl
's private _readPortletXML
method.
Edit:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With