2011-03-24 111 views

回答

10

有在Liferay中没有社区的实体,它只是另一种组(见GroupConstants

如果你有机会到ThemeDisplay对象,我认为这会给你的社区的标识

long id = themeDisplay.getLayout().getGroupId(); 

在Struts动作,你可以得到ThemeDisplay这样的:

ThemeDisplay themeDisplay = 
    (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY); 

其中request可以是RenderRequestActionRequest

+0

谢谢,但themeDisplay不工作,我已经试过了。 Eclipse说“themeDisplay无法解析”。我可以通过创建变量themeDisplay来修复它,但必须先初始化,并且我只能将它初始化为null。自然,如果它初始化为null,它将不起作用。谢谢 - Pat – 2011-03-25 07:59:13

+0

我已更新答案以显示您如何访问ThemeDisplay对象。 – blank 2011-03-25 09:03:10

+0

嗨,我在一段时间后才开始工作。我必须实现PortletRequestListener并在onRequestStart函数中初始化该themeDisplay!非常感谢你的队友! – 2011-03-25 11:08:30

1

对于那些你们谁使用Spring MVC作为Liferay的Portlet添加这个到ControllerClass

 @ModelAttribute("tD") 
    public String getThemeDisplay(RenderRequest req) { 
     ThemeDisplay themeDisplay = (ThemeDisplay) req.getAttribute(WebKeys.THEME_DISPLAY); 
     return themeDisplay.getPathThemeImages(); 
    } 

为参考,在JSP的图像只需添加

<img src="${tD}/[image-path] /> 

希望这有助于。