com.caucho.portal.generic
Interface Window

All Known Implementing Classes:
GenericLayoutWindow, GenericPortletWindow, GenericWindow, PortletServlet

public interface Window

A Window represents the use of a portlet on a page. The Window interface is the main point of contact between a portal implementation and the generic portlet codebase.


Method Summary
 int getBufferSize()
          Return a preferred buffer size, may be overridden by the portlet if it calls setBufferSize().
 java.util.ArrayList<Constraint> getConstraints()
          Return a list of Constraint that are applied before the processAction() and render() of the portlet are called, null if there are no Constraints.
 PortletPreferences getDefaultPreferences()
          Return the default preferences for the portlet, null if there are no default preferences.
 int getExpirationCache()
          Time in seconds, 0 disables caching and -1 means never expire.
 PortletConfig getPortletConfig()
           
 java.util.ArrayList<PreferencesValidator> getPreferencesValidators()
          Return the preferences validators for the portlet, null if there are no preference validators.
 Renderer getRenderer()
           
 java.util.Map<java.lang.String,java.lang.String> getRoleRefMap()
          Return a map that map's role names used by the portlet to the role names recognized by the portal, null if the role names used by the portlet are to be used unchanged.
 java.util.Set<java.lang.String> getSupportedContentTypes(PortletMode portletMode)
          Return the content types supported for the mode, null if all content types are permitted.
 java.util.Set<java.util.Locale> getSupportedLocales()
          Return the Locales supported, null if all Locales are permitted.
 void handleConstraintFailure(RenderRequest request, RenderResponse response, ConstraintFailureEvent event)
          Optionally handle a constraint failure by sending some output to the client using the response or by hiding the window.
 void handleException(RenderRequest renderRequest, RenderResponse renderResponse, ExceptionEvent exceptionEvent)
          Optionally handle an exception by sending some output to the client using the response or by hiding the window.
 PortletMode handlePortletModeFailure(PortletRequest request, PortletMode notAllowed)
          This is called when a request arrives requesting a PortletMode that does not pass the isPortletModeAllowed() tests.
 WindowState handleWindowStateFailure(PortletRequest request, WindowState notAllowed)
          This is called when a request arrives requesting a WindowState that does not pass the isWindowStateAllowed() tests.
 boolean isPortletModeAllowed(PortletRequest request, PortletMode portletMode)
          Return true if the PortletMode is allowed.
 boolean isPrivate()
          Return true if the contents of the portlet are private.
 boolean isWindowStateAllowed(PortletRequest request, WindowState windowState)
          Return true if the WindowState is allowed.
 

Method Detail

getPortletConfig

PortletConfig getPortletConfig()

getRenderer

Renderer getRenderer()

getExpirationCache

int getExpirationCache()
Time in seconds, 0 disables caching and -1 means never expire.


isPrivate

boolean isPrivate()
Return true if the contents of the portlet are private. The portlet specification states that "cached content must not be shared across different user clients displaying the same portlet". If a portal implementation supports caching, then a return value of false will allow the portal to share the cached content across different user clients.


getDefaultPreferences

PortletPreferences getDefaultPreferences()
Return the default preferences for the portlet, null if there are no default preferences.


getPreferencesValidators

java.util.ArrayList<PreferencesValidator> getPreferencesValidators()
Return the preferences validators for the portlet, null if there are no preference validators.


getRoleRefMap

java.util.Map<java.lang.String,java.lang.String> getRoleRefMap()
Return a map that map's role names used by the portlet to the role names recognized by the portal, null if the role names used by the portlet are to be used unchanged.


getConstraints

java.util.ArrayList<Constraint> getConstraints()
Return a list of Constraint that are applied before the processAction() and render() of the portlet are called, null if there are no Constraints.


getSupportedContentTypes

java.util.Set<java.lang.String> getSupportedContentTypes(PortletMode portletMode)
Return the content types supported for the mode, null if all content types are permitted.


getSupportedLocales

java.util.Set<java.util.Locale> getSupportedLocales()
Return the Locales supported, null if all Locales are permitted.


getBufferSize

int getBufferSize()
Return a preferred buffer size, may be overridden by the portlet if it calls setBufferSize(). A value of 0 disables buffering for the portlet. A value of -1 allows the portal to use a default buffer size.


isWindowStateAllowed

boolean isWindowStateAllowed(PortletRequest request,
                             WindowState windowState)
Return true if the WindowState is allowed. portletRequest.getResponseContentType() can be used if the allowed portlet modes depends on the mime type of the response.


isPortletModeAllowed

boolean isPortletModeAllowed(PortletRequest request,
                             PortletMode portletMode)
Return true if the PortletMode is allowed. portletRequest.getResponseContentType() can be used if the allowed portlet modes depends on the mime type of the response.


handlePortletModeFailure

PortletMode handlePortletModeFailure(PortletRequest request,
                                     PortletMode notAllowed)
This is called when a request arrives requesting a PortletMode that does not pass the isPortletModeAllowed() tests. It gives the Window an opportunity to return a PortletMode that can be used. If the returned mode is also not allowed, a PortletModeException occurs. Implementations can use handleException to handle PortletModeException.

Returns:
a new PortletMode to try, or null to cause an exception.

handleWindowStateFailure

WindowState handleWindowStateFailure(PortletRequest request,
                                     WindowState notAllowed)
This is called when a request arrives requesting a WindowState that does not pass the isWindowStateAllowed() tests. It gives the Window an opportunity to return a WindowState that can be used. If the returned window state is also not allowed, a WindowStateException occurs. Implementations can use handleException to handle WindowStateException.

Returns:
a new WindowState to try, or null to cause an exception,

handleConstraintFailure

void handleConstraintFailure(RenderRequest request,
                             RenderResponse response,
                             ConstraintFailureEvent event)
                             throws java.io.IOException,
                                    PortletException
Optionally handle a constraint failure by sending some output to the client using the response or by hiding the window. When a Portlet fails a Constriant during processAction(), it is stored until the render stage, and handleConstriantFailure() is called instead of render(). When a Portlet fails a Constraint during render(), handleConstriantFailure() is immediately called. If the implementation of this method does nothing, then the response of this window is reset() and the failure propagates to the parent window. If there is no parent window, PortletConnection#handleConstraintFailure() is called. Implementations of this method can change that behaviour by using the event.setHandled(boolean hideWindow) callback method. See handleException(RenderRequest, RenderResponse, com.caucho.portal.generic.ExceptionEvent) for more information.

Throws:
java.io.IOException
PortletException

handleException

void handleException(RenderRequest renderRequest,
                     RenderResponse renderResponse,
                     ExceptionEvent exceptionEvent)
                     throws java.io.IOException,
                            PortletException
Optionally handle an exception by sending some output to the client using the response or by hiding the window. When a Portlet throws an Exception during processAction(), it is stored until the render stage, and handleException() is called instead of render(). When a Portlet throws an exception during render(), the handleException() is immediately called. If the implementation of this method does nothing, then the repsonse of this window is reset() and the exception propagates to the parent window. If there is no parent window, PortletConnection#handleException() is called. Implementations of this method can change that behaviour by using the event.setHandled(boolean hideWindow) callback method.

exceptionEvent.setHandled(false)

If handleException calls exceptionEvent.setHandled(false) then the content that the portlet has written is kept, and the request continues. Implementations use this when they have written some contents to the portlet that should be visible to the user.
 public void handleException(RenderRequest request, RenderResponse response, ExceptionEvent event)
   throws PortletException, IOException 
 {
   if (event.getException() instanceof UnavailableException) {
     PrintWriter out = response.getWriter();
     response.setContentType("text/html"); 
     out.println("This service is currently unavailable."); 
     event.setHandled(false);
   } 
 } 
 
If an implementation is handling an exception that can occur after the Portlet has written some content already, it should call response.reset() before it writes anything to the response.
 public void handleException(RenderRequest request, RenderResponse response, ExceptionEvent event)
   throws PortletException, IOException 
 {
   response.reset(); 
   response.setContentType("text/html"); 
   PrintWriter out = response.getWriter();
   printFancyExceptionMessage(event.getException());
   event.setHandled(false);
 } 
 

exceptionEvent.setHandled(true)

If handleException calls exceptionEvent.setHandled(true) then the output is reset(), including any output from a Renderer, and the request continues. The effect of this call is to make the window invisible, no content for this window is shown but other windows on the page will be shown. Implementations use this when they have dealt with the exception in some way and wish to hide the exception from the user.
 public void handleException(ExceptionEvent event)
   throws PortletException, IOException 
 {
   log.log(Level.WARNING, ex.toString(), ex);
   event.setHandled(true); 
 } 
 

Throws:
java.io.IOException
PortletException