Portal Showcase
portal:runtime
Runtime is a UIPanel component that embeds the markup of a different portlet within the current portlet.Multiple Instances Usage
Multiple instances can be specified by appending_INSTANCE_
and a unique suffix to the value of the portletName attribute. The portlet must have <instanceable>true</instanceable>
in the liferay-portlet.xml descriptor in order to support multiple instances.
Liferay Portal is an enterprise web platform for building business solutions that deliver immediate results and long-term value.
Liferay Faces is an open source umbrella project that provides support for the JavaServer™ Faces (JSF) standard in webapp and portlet projects. [Issue Tracker] [Forums] [Tutorials] |
Forráskód
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:portal="http://liferay.com/faces/portal"> <!-- Embed Web Content Display portlet for "Liferay Portal" article. --> <portal:runtime portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet_INSTANCE_ABCD1234" defaultPreferences="#{runtimeBacking.preferencesArticle1}" /> <!-- Embed Web Content Display portlet for "Liferay Faces" article. --> <portal:runtime portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet_INSTANCE_WXYZ0987" defaultPreferences="#{runtimeBacking.preferencesArticle2}" /> </ui:composition>
@ManagedBean @ApplicationScoped public class RuntimeBacking { // Logger private static final Logger logger = LoggerFactory.getLogger(RuntimeBacking.class); // Private Data Members private String preferencesArticle1; private String preferencesArticle2; private String preferencesArticle3; public String getPreferencesArticle1() { return preferencesArticle1; } public String getPreferencesArticle2() { return preferencesArticle2; } @PostConstruct public void postConstruct() { FacesContext facesContext = FacesContext.getCurrentInstance(); Map<String, Object> requestAttributeMap = facesContext.getExternalContext().getRequestMap(); ThemeDisplay themeDisplay = (ThemeDisplay) requestAttributeMap.get(WebKeys.THEME_DISPLAY); try { long companyId = themeDisplay.getCompanyId(); long userId = themeDisplay.getUserId(); long groupId = themeDisplay.getScopeGroupId(); long folderId = DLFolderConstants.DEFAULT_PARENT_FOLDER_ID; Locale locale = themeDisplay.getLocale(); StringBuilder content1 = new StringBuilder(9); content1.append("<?xml version=\"1.0\"?>"); content1.append("<root available-locales=\"en_US\" default-locale=\"en_US\">"); content1.append( "<dynamic-element name=\"content\" type=\"text_area\" index-type=\"keyword\" instance-id=\"zeun\">"); content1.append("<dynamic-content language-id=\"en_US\"><![CDATA["); content1.append( "<p>Liferay Portal is an enterprise web platform for building business solutions that deliver "); content1.append("immediate results and long-term value.</p>"); content1.append("]]></dynamic-content>"); content1.append("</dynamic-element>"); content1.append("</root>"); JournalArticle article1 = WebContentUtil.getArticle(companyId, userId, groupId, folderId, locale, "Liferay Portal", content1.toString()); this.preferencesArticle1 = getPreferences(article1.getGroupId(), article1.getArticleId()); StringBuilder content2 = new StringBuilder(9); content2.append("<?xml version=\"1.0\"?>"); content2.append("<root available-locales=\"en_US\" default-locale=\"en_US\">"); content2.append( "<dynamic-element name=\"content\" type=\"text_area\" index-type=\"keyword\" instance-id=\"yujh\">"); content2.append("<dynamic-content language-id=\"en_US\"><![CDATA["); content2.append( "<p>Liferay Faces is an umbrella project that provides support for the JavaServer™ Faces (JSF) "); content2.append("standard within Liferay Portal.</p>"); content2.append("]]></dynamic-content>"); content2.append("</dynamic-element>"); content2.append("</root>"); JournalArticle article2 = WebContentUtil.getArticle(companyId, userId, groupId, folderId, locale, "Liferay Faces", content2.toString()); this.preferencesArticle2 = getPreferences(article2.getGroupId(), article2.getArticleId()); } catch (Exception e) { logger.error(e); } } protected String getPreferences(long groupId, String articleId) { StringBuilder buf = new StringBuilder(); buf.append("<portlet-preferences>"); buf.append("<preference>"); buf.append("<name>groupId</name>"); buf.append("<value>"); buf.append(groupId); buf.append("</value>"); buf.append("</preference>"); buf.append("<preference>"); buf.append("<name>articleId</name>"); buf.append("<value>"); buf.append(articleId); buf.append("</value>"); buf.append("</preference>"); buf.append("<preference>"); buf.append("<name>portletSetupShowBorders</name>"); buf.append("<value>true</value>"); buf.append("</preference>"); buf.append("</portlet-preferences>"); return buf.toString(); } }
Liferay Faces Bridge Implementation 5.0.0 + Liferay Faces Portal 5.0.0 + Showcase Common 3.1.1 + Liferay Faces Util 3.4.1 + Mojarra 2.2.20