LIFERAY 6.2 - 将 Web 内容发送到另一个页面的另一个 Portlet
LIFERAY 6.2 - Send a Web Content to another Portlet at another Page
我正在使用 Liferay 6.2,我很难在另一个 portlet "portlet-asset-publisher" 上显示 "portlet-journal-content-search" 的 Web 内容,该内容保留在另一个页面中。
我更大的困难是我需要在搜索 Web 内容后,系统显示所有结果 Link "display page",以及 portlet "portlet-asset-publisher"。每个结果都必须有一个动态生成的 link,因为每个结果都会有不同的 "display page".
我试图在代码中找到有关网页内容 "display page" 的信息所在的位置,但没有找到。
我想我会使用 Liferay 标签 "renderURL" 来执行此操作,但我不知道我将如何发送我的内容以及如何动态获取 "display page"!
今天,当我单击 link 以重定向到我的内容时,我会转到同一页面和 portlet“.portlet-journal-content”。
代码如下:
<%
PortletURL webContentPortletURL = PortletURLFactoryUtil.create(request, targetPortletId, plid, PortletRequest.RENDER_PHASE);
webContentPortletURL.setParameter("struts_action", "/journal_content/view");
webContentPortletURL.setParameter("groupId",
String.valueOf(articleGroupId));
webContentPortletURL.setParameter("articleId", articleId);
%>
<br />
<a href="<%= webContentPortletURL.toString() %>"><%= StringUtil.shorten(webContentPortletURL.toString(), 100) %></a>
但是我需要被重定向到我的内容的"Display Page"(截图页面的"TestandoPagina"名称),并且它必须显示在portlet ".portlet-asset-publisher ”。
我尝试执行但不起作用的代码是:
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
String portletId = PortletKeys.ASSET_PUBLISHER;
long otherPlid = PortalUtil.getPlidFromPortletId(themeDisplay.getScopeGroupId(), portletId);
%>
<liferay-portlet:renderURL var="testURL" plid="<%=otherPlid%>" portletName="<%=portletId%>">
<liferay-portlet:param name="groupId" value="<%= String.valueOf(articleGroupId) %>" />
<liferay-portlet:param name="articleId" value="<%= articleId %>" />
</liferay-portlet:renderURL>
<br /><a href="<%= testURL %>"><%= StringUtil.shorten(testURL.toString(), 100) %></a>
有人可以帮我吗?
非常感谢。
下面是它现在如何工作的一些截图:
A Web Content example with his "Display Page" called "TestandoPagina"
然后我在“.portlet-journal-content-search”搜索网页内容。
The result of my research with the "wrong" Links
今天我点击这个 Link 会发生什么,我停留在同一页面 "Processos" 并且我的内容显示在“.portlet-journal-content”,我想去他的 "display page",在此示例中称为 "TestandoPagina",内容显示在“.portlet-asset-publisher”。
我做到了!
这样做的要点是:
1st - 知道 "layoutUuid" 是 Web 内容 "Display Page" 的 ID,因此我可以获得 PLID、属于该页面的所有 PortletId 等信息。
2nd - 获取 "Document" 的信息我可以创建一个 "AssetEntry".
这就是我获取 "Display Page" 信息的方式:
<%
ResultRow row = (ResultRow) request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);
Object[] objArray = (Object[])row.getObject();
Document doc = (Document)objArray[1];
String layoutUuid = doc.get("layoutUuid");
Layout specificLayout = LayoutLocalServiceUtil.getLayoutByUuidAndCompanyId( layoutUuid, PortalUtil.getDefaultCompanyId() );
specificPlid = specificLayout.getPlid();
articleLayoutTypePortlet = (LayoutTypePortlet) specificLayout.getLayoutType();
List<Portlet> allPortlets = articleLayoutTypePortlet.getAllPortlets();
for (Portlet portlet : allPortlets){
if ( PortletKeys.ASSET_PUBLISHER.equals( portlet .getRootPortletId() ) ) {
portletId = PortletKeys.ASSET_PUBLISHER + PortletConstants.INSTANCE_SEPARATOR + portlet .getInstanceId();
break;
}
}
%>
之后,我创建 AssetEntry 以获取 "assetEntryId",然后最终创建动态 link:
<%
String className = doc.get("entryClassName");
Long classPk = Long.parseLong( doc.get("entryClassPK") );
AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPk);
Long assetEntryId = assetEntry.getEntryId();
webContentPortletURL = PortletURLFactoryUtil.create(request, portletId, specificPlid, PortletRequest.RENDER_PHASE);
webContentPortletURL.setParameter( "struts_action", "/asset_publisher/view_content" );
webContentPortletURL.setParameter( "groupId", String.valueOf(articleGroupId) );
webContentPortletURL.setParameter( "type", "content" );
webContentPortletURL.setParameter( "assetEntryId", String.valueOf(assetEntryId) );
webContentPortletURL.setParameter( "articleId", articleId );
%>
我在 "journal_content_search/article_content.jsp"
所做的所有更改
希望对很多人有帮助!
我正在使用 Liferay 6.2,我很难在另一个 portlet "portlet-asset-publisher" 上显示 "portlet-journal-content-search" 的 Web 内容,该内容保留在另一个页面中。
我更大的困难是我需要在搜索 Web 内容后,系统显示所有结果 Link "display page",以及 portlet "portlet-asset-publisher"。每个结果都必须有一个动态生成的 link,因为每个结果都会有不同的 "display page".
我试图在代码中找到有关网页内容 "display page" 的信息所在的位置,但没有找到。
我想我会使用 Liferay 标签 "renderURL" 来执行此操作,但我不知道我将如何发送我的内容以及如何动态获取 "display page"!
今天,当我单击 link 以重定向到我的内容时,我会转到同一页面和 portlet“.portlet-journal-content”。 代码如下:
<%
PortletURL webContentPortletURL = PortletURLFactoryUtil.create(request, targetPortletId, plid, PortletRequest.RENDER_PHASE);
webContentPortletURL.setParameter("struts_action", "/journal_content/view");
webContentPortletURL.setParameter("groupId",
String.valueOf(articleGroupId));
webContentPortletURL.setParameter("articleId", articleId);
%>
<br />
<a href="<%= webContentPortletURL.toString() %>"><%= StringUtil.shorten(webContentPortletURL.toString(), 100) %></a>
但是我需要被重定向到我的内容的"Display Page"(截图页面的"TestandoPagina"名称),并且它必须显示在portlet ".portlet-asset-publisher ”。 我尝试执行但不起作用的代码是:
<portlet:defineObjects />
<liferay-theme:defineObjects />
<%
String portletId = PortletKeys.ASSET_PUBLISHER;
long otherPlid = PortalUtil.getPlidFromPortletId(themeDisplay.getScopeGroupId(), portletId);
%>
<liferay-portlet:renderURL var="testURL" plid="<%=otherPlid%>" portletName="<%=portletId%>">
<liferay-portlet:param name="groupId" value="<%= String.valueOf(articleGroupId) %>" />
<liferay-portlet:param name="articleId" value="<%= articleId %>" />
</liferay-portlet:renderURL>
<br /><a href="<%= testURL %>"><%= StringUtil.shorten(testURL.toString(), 100) %></a>
有人可以帮我吗? 非常感谢。
下面是它现在如何工作的一些截图:
A Web Content example with his "Display Page" called "TestandoPagina"
然后我在“.portlet-journal-content-search”搜索网页内容。
The result of my research with the "wrong" Links
今天我点击这个 Link 会发生什么,我停留在同一页面 "Processos" 并且我的内容显示在“.portlet-journal-content”,我想去他的 "display page",在此示例中称为 "TestandoPagina",内容显示在“.portlet-asset-publisher”。
我做到了!
这样做的要点是:
1st - 知道 "layoutUuid" 是 Web 内容 "Display Page" 的 ID,因此我可以获得 PLID、属于该页面的所有 PortletId 等信息。
2nd - 获取 "Document" 的信息我可以创建一个 "AssetEntry".
这就是我获取 "Display Page" 信息的方式:
<%
ResultRow row = (ResultRow) request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW);
Object[] objArray = (Object[])row.getObject();
Document doc = (Document)objArray[1];
String layoutUuid = doc.get("layoutUuid");
Layout specificLayout = LayoutLocalServiceUtil.getLayoutByUuidAndCompanyId( layoutUuid, PortalUtil.getDefaultCompanyId() );
specificPlid = specificLayout.getPlid();
articleLayoutTypePortlet = (LayoutTypePortlet) specificLayout.getLayoutType();
List<Portlet> allPortlets = articleLayoutTypePortlet.getAllPortlets();
for (Portlet portlet : allPortlets){
if ( PortletKeys.ASSET_PUBLISHER.equals( portlet .getRootPortletId() ) ) {
portletId = PortletKeys.ASSET_PUBLISHER + PortletConstants.INSTANCE_SEPARATOR + portlet .getInstanceId();
break;
}
}
%>
之后,我创建 AssetEntry 以获取 "assetEntryId",然后最终创建动态 link:
<%
String className = doc.get("entryClassName");
Long classPk = Long.parseLong( doc.get("entryClassPK") );
AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(className, classPk);
Long assetEntryId = assetEntry.getEntryId();
webContentPortletURL = PortletURLFactoryUtil.create(request, portletId, specificPlid, PortletRequest.RENDER_PHASE);
webContentPortletURL.setParameter( "struts_action", "/asset_publisher/view_content" );
webContentPortletURL.setParameter( "groupId", String.valueOf(articleGroupId) );
webContentPortletURL.setParameter( "type", "content" );
webContentPortletURL.setParameter( "assetEntryId", String.valueOf(assetEntryId) );
webContentPortletURL.setParameter( "articleId", articleId );
%>
我在 "journal_content_search/article_content.jsp"
所做的所有更改希望对很多人有帮助!