Friday, June 29, 2018

Open Web Content in Control Panel from your Custom Portlet


Today we will open Web Content Edit Page from our custom portlet.We already know how to write struts action hook here we use the same approach. We create a simple portlet and provide a link on click of that link we open the web content in control panel.


Just Use this code in your jsp:-

<%@page import="java.util.Locale"%>
<%@page import="javax.portlet.WindowState"%>
<%@page import="com.liferay.portlet.journal.model.JournalArticle"%>
<%@page import="com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil"%>
<%@page import="com.liferay.portal.util.PortletKeys"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<%
JournalArticle article = JournalArticleLocalServiceUtil.getLatestArticle(11609);
%>
<liferay-portlet:renderURL windowState="<%= WindowState.MAXIMIZED.toString() %>" var="editURL" portletName="<%= PortletKeys.JOURNAL %>" doAsGroupId="<%=article.getGroupId()%>">
<portlet:param name="struts_action" value="/journal/edit_article" />
<portlet:param name="groupId" value="<%=String.valueOf(article.getGroupId())%>" />
<portlet:param name="folderId" value="<%= String.valueOf(article.getFolderId()) %>" />
<portlet:param name="articleId" value="<%=String.valueOf(article.getArticleId())%>" />
<portlet:param name="version" value="<%=String.valueOf(article.getVersion())%>" />
</liferay-portlet:renderURL>
Click Here to Edit Web Content:-
<a href="${editURL}"><%=article.getTitle(Locale.ENGLISH)%></a>
view raw view.jsp hosted with ❤ by GitHub



Hope this will Help....

Related Post:-

No comments:

Post a Comment

Total Pageviews

1042247

Number Of Unique Visitor

Free counters!