5.2 Window events

 <  Day Day Up  >  

Window events are sent by the portlet container when a user modifies the window's state by clicking control buttons such as the maximize or minimize buttons . To receive window events, you have to implement the WindowListener interface at the portlet class.

Note

The WindowEvent interface is deprecated; use PortletWindow.getWindowState() instead.


In the next example, the doView() method checks whether the window is maximized to set a parameter that the JSP page uses to display more information about each entry of the agenda.

Example 5-5. Get the window state.
 public void doView(PortletRequest request, PortletResponse response)              throws PortletException, IOException {    PortletWindow.State state = request.getWindow().getWindowState();    if ( state == PortletWindow.State.MAXIMIZED )       request.setAttribute("detail", "1");    else       request.setAttribute("detail", "0");    ....... 

The JSP checks detail attribute and displays information depending on its value. Figure 5-1 and Figure 5-2 show the results depending on the window state.

Figure 5-1. Information shown when the window is not maximized

graphics/05fig01.gif

Figure 5-2. Information shows when the window is maximized

graphics/05fig02.gif

 <  Day Day Up  >  


IBM WebSphere Portal V5 A Guide for Portlet Application Development
IBM Websphere Portal V5: A Guide for Portlet Application Development
ISBN: 0738498513
EAN: 2147483647
Year: 2004
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net