Portal Showcase

portal:runtime

Runtime is a UIPanel component that embeds the markup of a different portlet within the current portlet.

General Usage

The general usage is to specify the embedded portlet by its name. The name of an out-of-the-box Liferay portlet can be determined by examining the portlet-name element of the portal's liferay-portlet.xml descriptor.

Hello World

Welcome to Liferay Community Edition Portal 7.0.2 GA3 (Wilberforce / Build 7002 / August 5, 2016).

Source Code

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:portal="http://liferay.com/faces/portal">

	<!-- Embed the out-of-the-box Liferay Hello World Portlet -->
	<portal:runtime portletName="com_liferay_hello_world_web_portlet_HelloWorldPortlet" />

</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 4.1.0 + Liferay Faces Portal 3.0.1 + Showcase Common 3.0.1 + Liferay Faces Util 3.1.0 + Mojarra 2.2.14