开发者

How can I get current group id (or community id) in liferay (java)?

I'm developing portlet with Vaadin in Liferay 6 and I need to get the ID of the commun开发者_Python百科ity where the portlet is located. How is it done?


There is no Community entity in Liferay, it's just another kind of group (see GroupConstants)

If you have access to a ThemeDisplay object I think this will give you the Id of the community

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

In a struts action you can get ThemeDisplay like this:

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

where request can be a RenderRequest or an ActionRequest.


For those of you who use Spring MVC as Liferay portlets add this to the ControllerClass

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

To refere to an image in jsp just add

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜