5 Replies Latest reply on Aug 27, 2010 3:59 AM by phdezann

    Can't change WindowState in processAction or processEvent

    phdezann

      Hi there,

      I'm having some problems trying to change the WindowState of a portlet to something else than 'WindowState.NORMAL'. In a very simple action, here is what I do:
      @Override
      public void processAction(ActionRequest request, ActionResponse response)
      throws PortletException, IOException {
        response.setWindowState(WindowState.MINIMIZED);
      }
      However, when the doView method is called right after this action, the current window state is always set to 'WindowState.NORMAL'.
      protected void doView(RenderRequest request, RenderResponse response)
      throws PortletException, IOException {
        WindowState windowState = request.getWindowState();
        // here the windowState is always equal to WindowState.NORMAL
        ...
      }
      The same behaviour has been seen when using an event like:
      @Override
      public void processEvent(EventRequest request, EventResponse response)
      throws PortletException, IOException {
        response.setWindowState(WindowState.MINIMIZED);
      }
      There is no doubt that these calls are made as I see them with my debugger. I'm using GateIn 3.1.0 with Tomcat with no modifications whatsoever.
      Is there something I have misunderstood?
      Thank you very much for your help.
        • 1. Re: Can't change WindowState in processAction or processEvent
          hoang_to

          Please give details of how did you debug

           

          As i know, in GateIn 3.1, the render request is not invoked if the window state is MINIMIZED. That might explain why in this special case,  window state parameter of a render request is not coherent to window state changes in preceding action/event requests.

          • 2. Re: Can't change WindowState in processAction or processEvent
            phdezann

            Thanks for your quick reply.

             

            Note that I don't click on any icons for maximizing or minimizing a portlet. What I want to do is to minimize a portlet from an event sent by another portlet (both portlets being on the same page).

             

            Here is the scenario :

            - The user clicks on a link on the PortletA and triggers an action

            - The action sends an event

            - The PortletB receives the event sent by the PortletA and calls setWindowState(WindowState.MINIMIZED) on the EventResponse object

             

            At this point, the PortletA should be displayed and the PortletB minimized, right?

             

            The behavious I have is that the doView method of the PortletB is still called and this call is made with a WindowState set to WindowState.NORMAL. Consequently PortletB renders its ouput.

             

            Nevertheless, the JSR 286 states the following :

             

            PLT.12.2.2 Portlet Modes and Window State Changes
            ...

            The setWindowState method allows a portlet to change its current window state. The new window state will be effective in the following processEvent and render requests. If a portlet attempts to set a window state that it is not allowed to switch to, a WindowStateException must be thrown.
            Portlets cannot assume that subsequent processEvent or render calls will be called with the set portlet mode or window state as the portal/portlet-container could override these changes.

             

            Does this last paragraph mean that the portal must be configured to pass the WindowState set in the processAction or in the processEvent to the render call ?

            • 3. Re: Can't change WindowState in processAction or processEvent
              hoang_to

              In GateIn, each portlet window is represented by an UIPortlet object. The request handling flow on an UIPortlet is described as following:

               

              1. User trigger an action on the UI component UIPortlet

               

              2. UI Event (ex: change mode, window states of the UIPortlet component) is fired, relevant event listener reset the states of UIPortlet object

               

              3. 'ProcessAction' UI Event is firedthat makes an Action Invocation tobe sent to Portlet Container ( parameters of ActionRequest are taken from UIPortlet object), that might result in portlet event requests

               

              4. UIPortlet is added to 'update by AJAX' UI components, processRender method of the UIPortlet is called

               

              5. Render Invocation is sent to Portlet Container (parameters of RenderRequest are taken from UIPortlet object) (*)

               

              Upto 3.1 release, there is no (*) if  WindowState of UIPortlet object is MINIMIZED

               

               

              So please debug to see if the WindowState of UIPortlet object representing your porltet window B is set to MINIMIZED

              • 4. Re: Can't change WindowState in processAction or processEvent
                trong.tran

                Hi Pierre-Henri,

                 

                This is definitely a bug. Actually i have tried to setWindowState in an ActionURL but it does not work too.

                 

                I have addressed this to a JIRA https://jira.jboss.org/browse/GTNPORTAL-1446, so you can watch its activity

                 

                Thanks for your experiment.

                • 5. Re: Can't change WindowState in processAction or processEvent
                  phdezann

                  Thank you very much for this.