0

我正在使用 Liferay 6 和 MVC portlet。我使用 jsp 和 extjs 来呈现我的 portlet。当我最大化/最小化时,portlet 的当前状态会丢失。即使在最大化/最小化之后,我也想保留 portlet 的状态。我怎样才能做到这一点?

谢谢

4

1 回答 1

1

Portlet 有两个阶段:动作阶段和呈现阶段。当某些状态必须改变时,动作阶段将运行,例如。当表单提交完成时。渲染阶段将始终运行,在最大化/最小化之后也是如此。如果您不希望在渲染阶段更改某些状态,请将此逻辑置于操作阶段。

通过 MVC-Portlet,您有两种方法来处理每个阶段:

public class MyLiferayTestPortlet extends MVCPortlet {
    @Override
    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException {
        System.out.println("action");
        //here you can change the state
    }

    @Override
    public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
        System.out.println("rendering");
        //here you can prepaire the rendering of jsp

        //print the window state
        ThemeDisplay td = (ThemeDisplay)renderRequest.getAttribute(WebKeys.THEME_DISPLAY);
        System.out.println("isStateMaximized: " + td.isStateMaximized());
    }
}

在这里您可以阅读有关 portlet 的两个阶段的信息: http ://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/understanding-the-two-phases-of-portlet-executi-4

于 2012-08-07T09:19:55.100 回答