3 Replies Latest reply on Oct 17, 2006 7:18 AM by theute

    programatically set window state to Maximized

    bhupeshs


      I have to set the window state to maximized for a portlet in the doView/doEdit method of the portlet class. How can this be achieved?

        • 1. Re: programatically set window state to Maximized
          theute

          The portlet spec is your friend:

          PLT.7.1.1 Including a Portlet Mode or a Window State
          A portlet URL can include a specific portlet mode (see PLT.8 Portlet Modes Chapter) or
          window state (see PLT.9 Window States Chapter). The PortletURL interface has the
          setWindowState and setPortletMode methods for setting the portlet mode and window
          state in the portlet URL. For example:
          ...
          PortletURL url = response.createActionURL();
          url.setParameter(?paymentMethod?,?creditCardInProfile?);
          url.setWindowState(WindowState.MAXIMIZED);
          writer.print(?<FORM METHOD=\?POST\? ACTION=\??+ url.toString()+?\?>?);
          ...


          • 2. Re: programatically set window state to Maximized
            bhupeshs


            Assume that whenever the edit button is clicked on the portlet, the portlet has to be displayed in maximized mode. Here the user is not clicking on a portlet url but the standard edit button of the portlet window.

            since the maximize has to happen everytime, I thought of putting the code in the doEdit(...) method. I see that the ActionResponse has the method setWindowState() but not the RenderResponse.

            so my code should look something like

            protected void doEdit(RenderRequest request, RenderResponse response)
            throws PortletException, IOException
            {
            // ** put code to maximize the window. **

            // Edit View logic goes here.
            facesRender(request, response);
            }

            • 3. Re: programatically set window state to Maximized
              theute

              Yes, you can only change the state in the action method. In the render method it is already too late so you cannot do what you are looking for.