我目前正在使用部署在本地计算机(Win 7/x64)上的Liferay Portal Enterprise Edition 6.1 EE GA1(Paton/Build 6110/2012年2月15日)进行开发和测试。它运行在标准的7.0.25 Tomcat中,我们使用Spring MVC开发我们的portlet。如何在Liferay 6.1中以编程方式设置“链接到页面”布局?
我正在以编程方式向Liferay添加新的布局(页面),并将类型的类型设置为“link_to_layout”(LayoutConstants.TYPE_LINK_TO_LAYOUT)。布局已成功创建,但到目前为止,我还没有弄清楚如何为链接设置值,例如像“/登录”。下面是我使用添加布局的代码:
// Spring specific code for getting the Request
HttpServletRequest request = null;
ServletRequestAttributes sa = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
if(null != sa){
request = sa.getRequest();
}
if (request == null) { break; }
// all values are usually retrieved via special methods from our code
// for better readability I have added the real values here
long userId = 10102;
int groupId = 13056;
boolean privateLayout = false;
long plid = LayoutConstants.DEFAULT_PARENT_LAYOUT_ID;
String title = "my title";
ServiceContext serviceContext = ServiceContextFactory.getInstance(request);
String layoutType = LayoutConstants.TYPE_LINK_TO_LAYOUT;
boolean hidden = false;
String friendlyURL = "/new-page";
// finally, add the layout
Layout layout = LayoutLocalServiceUtil.addLayout(userId, groupId, privateLayout, plid, title, title, StringPool.BLANK, layoutType, hidden, friendlyURL, serviceContext);
我现在可以手动验证页面已经被创建和页面类型已通过检查网站页面上的控制面板中设置为“link_to_layout” 。在那里,我看到一个空的“链接到页面”值的新页面。我还可以通过编程调用下面的代码验证这一点(这是显示在控制台消息):
if(layout.isTypeLinkToLayout()){
log.debug("type is link to page");
}
如果有谁知道如何链接的值设置为网页,请与我分享你的知识。 您的帮助非常感谢你的答案:-)
最好的问候, 马蒂亚斯