Accessing Liferay web content from inside a portlet?
Question
I have a Struts portlet being used in a Liferay Portal environment. I have been localizing my resource strings using standard resource files so far. I can access the message bundle from my portlet using the <bean:message>
tag, and it works great. So for example, in a form I might have the following label defined in my JSP file.
...
<label for="firstname">
<bean:message key='labels.firstname'/>
</label>
...
This works fine for short strings that don't change after compile time. I can localize my strings properly, compile my portlet, and it just works.
Problem: I have a requirement to allow portal content authors to modify content used in my portlet, on-the-fly, after compilation. My first thought was to use Liferay's web content system, so content authors could create localized web content pieces that I could access from my portlet's JSP files.
Question: Is a way to access Liferay web content from inside my portlet?
Solution
There is a tag from the liferay-ui that displays the content of a CMS "article" :
<liferay-ui:journal-article articleId="YOUR_ARTICLE_ID" groupId="<%= groupId %>" />
It can be used for example to display variable "terms of use", as explained here
You can also find some inspiration in the content display portlet jsps for a more flexible approach.
OTHER TIPS
Have you looked at the Content Management System included in liferay? That could be the answer to your need. It would allow content authors to create content in the CMS and then you could write template JSPs that would pull in the content from there.