我正在使用Liferay6.2,我很难在另一个portlet“portlet-”中显示“portlet-日志-内容-搜索”的web内容,该内容保留在另一个页面中。
我更大的困难是,在搜索web内容之后,我需要一个事实,即系统用链接显示所有结果,以显示它们的“显示页面”,并显示到portlet“portlet-”。每个结果都必须有一个动态生成的链接,因为每个结果都有不同的“显示页”。
我试着在代码中找到关于web内容的“显示页面”的信息,但我没有找到。
我想我应该使用Liferay标签"renderURL“来完成这个任务,但是我不知道如何发送我的内容,以及如何动态地获得”显示页面“!
今天,当我点击要重定向到我的内容的链接时,我会转到同一个页面和portlet“.portlet-日志内容”。守则是这样的:
<%
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>
但是我需要重定向到我的内容的“显示页面”(ScreenShot页面的“ScreenShot”名称),它必须显示在portlet“.portlet-asset”中。我试图做的代码,但它不起作用,是:
<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>
有人能帮我吗?非常感谢。
下面是一些关于它现在是如何工作的截图:
他的“显示页”称为"TestandoPagina“的网页内容示例
然后,我在“..portlet日志-内容-搜索”中搜索web内容。
当我今天点击这个链接时会发生什么,我停留在同一个页面"Processos“,我的内容显示在”..portlet journal- content“中,我想转到他的"display页面”,在这个名为"TestandoPagina“的例子中,内容显示在”..portlet资产-发布者“上。
发布于 2016-11-18 11:36:14
我做到了!
这样做的要点是:
第一-知道"layoutUuid“是一个网页内容的”显示页面“的Id,所以我可以获得像PLID这样的信息,所有属于该页面的PortletIds等等。
第二次获取“文档”的信息,我可以创建一个"AssetEntry“。
这就是我如何获得“显示页”的信息:
<%
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“,然后最后创建dinnamic链接:
<%
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 );
%>
我在“日记_内容搜索/文章_content.jsp”中所做的所有更改
我希望这能帮助很多人!
https://stackoverflow.com/questions/40514323
复制相似问题