com.vaadin.terminal.gwt.server
Class AbstractApplicationPortlet

java.lang.Object
  extended by javax.portlet.GenericPortlet
      extended by com.vaadin.terminal.gwt.server.AbstractApplicationPortlet
All Implemented Interfaces:
Constants, javax.portlet.EventPortlet, javax.portlet.Portlet, javax.portlet.PortletConfig, javax.portlet.ResourceServingPortlet
Direct Known Subclasses:
ApplicationPortlet2

public abstract class AbstractApplicationPortlet
extends javax.portlet.GenericPortlet
implements Constants

Portlet 2.0 base class. This replaces the servlet in servlet/portlet 1.0 deployments and handles various portlet requests from the browser. TODO Document me!

Author:
peholmst

Nested Class Summary
 class AbstractApplicationPortlet.RequestError
           
protected static class AbstractApplicationPortlet.RequestType
           
 
Field Summary
static String PORTLET_PARAMETER_STYLE
          This portlet parameter is used to add styles to the main element.
 
Fields inherited from interface com.vaadin.terminal.gwt.server.Constants
AJAX_UIDL_URI, DEFAULT_BUFFER_SIZE, DEFAULT_THEME_CACHETIME, DEFAULT_THEME_NAME, DEFAULT_WIDGETSET, ERROR_NO_WINDOW_FOUND, INVALID_SECURITY_KEY_MSG, MAX_BUFFER_SIZE, NOT_PRODUCTION_MODE_INFO, PARAMETER_VAADIN_RESOURCES, PARAMETER_WIDGETSET, PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, PORTAL_PARAMETER_VAADIN_WIDGETSET, SERVLET_PARAMETER_DEBUG, SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, SERVLET_PARAMETER_PRODUCTION_MODE, SERVLET_PARAMETER_RESOURCE_CACHE_TIME, THEME_DIRECTORY_PATH, URL_PARAMETER_CLOSE_APPLICATION, URL_PARAMETER_REPAINT_ALL, URL_PARAMETER_RESTART_APPLICATION, URL_PARAMETER_THEME, WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC, WARNING_XSRF_PROTECTION_DISABLED, WIDGETSET_DIRECTORY_PATH
 
Constructor Summary
AbstractApplicationPortlet()
           
 
Method Summary
protected  void doDispatch(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response)
           
protected abstract  Class<? extends Application> getApplicationClass()
           
protected  String getApplicationOrSystemProperty(String parameterName, String defaultValue)
          Gets an application or system property value.
protected  String getApplicationProperty(String parameterName)
          Gets an application property value.
protected  ClassLoader getClassLoader()
           
protected  Application getNewApplication(javax.portlet.PortletRequest request)
           
protected  String getNoScriptMessage()
          Returns a message printed for browsers without scripting support or if browsers scripting support is disabled.
protected static String getPortalProperty(String name, javax.portlet.PortalContext context)
          Returns a portal configuration property.
protected  AbstractApplicationPortlet.RequestType getRequestType(javax.portlet.PortletRequest request)
           
protected  String getStaticFilesLocation(javax.portlet.PortletRequest request)
          Return the URL from where static files, e.g.
protected  Application.SystemMessages getSystemMessages()
          Get system messages from the current application class
protected  String getSystemProperty(String parameterName)
          Gets an system property value.
protected  String getThemeForWindow(javax.portlet.PortletRequest request, Window window)
          Returns the theme for given request/window
protected  String getThemeURI(String themeName, javax.portlet.PortletRequest request)
          Returns the theme URI for the named theme on the portal.
protected  Map<String,String> getVaadinConfigurationMap(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, Application application, String themeURI)
          Returns the configuration parameters to pass to the client.
protected  String getWidgetsetURL(String widgetset, javax.portlet.PortletRequest request)
          Returns the URL from which the widgetset is served on the portal.
protected  void handleRequest(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response)
           
 void init(javax.portlet.PortletConfig config)
           
 boolean isProductionMode()
          Returns true if the servlet is running in production mode.
 void processAction(javax.portlet.ActionRequest request, javax.portlet.ActionResponse response)
           
 void processEvent(javax.portlet.EventRequest request, javax.portlet.EventResponse response)
           
 void serveResource(javax.portlet.ResourceRequest request, javax.portlet.ResourceResponse response)
           
protected  void writeAjaxPage(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, Window window, Application application)
          Writes the html host page (aka kickstart page) that starts the actual Vaadin application.
protected  void writeAjaxPageHtmlMainDiv(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, BufferedWriter writer, String id, String classNames, String divStyle)
          Method to write the div element into which that actual Vaadin application is rendered.
protected  void writeAjaxPageHtmlTheme(javax.portlet.RenderRequest request, BufferedWriter writer, String themeName, String themeURI, String portalTheme)
          Writes the Vaadin theme loading section of the portlet HTML.
protected  void writeAjaxPageHtmlVaadinScripts(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, BufferedWriter writer, Application application, String themeName)
          This method writes the scripts to load the widgetset and the themes as well as define Vaadin configuration parameters on the HTML fragment that starts the actual Vaadin application.
protected  void writeAjaxPageScriptConfigurations(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, BufferedWriter writer, Map<String,String> config)
          Constructs the Vaadin configuration section for ApplicationConnection and ApplicationConfiguration.
protected  void writeAjaxPageScriptWidgetset(javax.portlet.RenderRequest request, javax.portlet.RenderResponse response, BufferedWriter writer)
          Writes the script to load the widgetset on the HTML fragment created by the portlet.
 
Methods inherited from class javax.portlet.GenericPortlet
destroy, doEdit, doHeaders, doHelp, doView, getContainerRuntimeOptions, getDefaultNamespace, getInitParameter, getInitParameterNames, getNextPossiblePortletModes, getPortletConfig, getPortletContext, getPortletName, getProcessingEventQNames, getPublicRenderParameterNames, getPublishingEventQNames, getResourceBundle, getSupportedLocales, getTitle, init, render
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PORTLET_PARAMETER_STYLE

public static final String PORTLET_PARAMETER_STYLE
This portlet parameter is used to add styles to the main element. E.g "height:500px" generates a style="height:500px" to the main element.

See Also:
Constant Field Values
Constructor Detail

AbstractApplicationPortlet

public AbstractApplicationPortlet()
Method Detail

init

public void init(javax.portlet.PortletConfig config)
          throws javax.portlet.PortletException
Specified by:
init in interface javax.portlet.Portlet
Overrides:
init in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException

getApplicationProperty

protected String getApplicationProperty(String parameterName)
Gets an application property value.

Parameters:
parameterName - the Name or the parameter.
Returns:
String value or null if not found

getSystemProperty

protected String getSystemProperty(String parameterName)
Gets an system property value.

Parameters:
parameterName - the Name or the parameter.
Returns:
String value or null if not found

getApplicationOrSystemProperty

protected String getApplicationOrSystemProperty(String parameterName,
                                                String defaultValue)
Gets an application or system property value.

Parameters:
parameterName - the Name or the parameter.
defaultValue - the Default to be used.
Returns:
String value or default if not found

getStaticFilesLocation

protected String getStaticFilesLocation(javax.portlet.PortletRequest request)
Return the URL from where static files, e.g. the widgetset and the theme, are served. In a standard configuration the VAADIN folder inside the returned folder is what is used for widgetsets and themes.

Parameters:
request -
Returns:
The location of static resources (inside which there should be a VAADIN directory). Does not end with a slash (/).

getRequestType

protected AbstractApplicationPortlet.RequestType getRequestType(javax.portlet.PortletRequest request)

isProductionMode

public boolean isProductionMode()
Returns true if the servlet is running in production mode. Production mode disables all debug facilities.

Returns:
true if in production mode, false if in debug mode

handleRequest

protected void handleRequest(javax.portlet.PortletRequest request,
                             javax.portlet.PortletResponse response)
                      throws javax.portlet.PortletException,
                             IOException
Throws:
javax.portlet.PortletException
IOException

processEvent

public void processEvent(javax.portlet.EventRequest request,
                         javax.portlet.EventResponse response)
                  throws javax.portlet.PortletException,
                         IOException
Specified by:
processEvent in interface javax.portlet.EventPortlet
Overrides:
processEvent in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

processAction

public void processAction(javax.portlet.ActionRequest request,
                          javax.portlet.ActionResponse response)
                   throws javax.portlet.PortletException,
                          IOException
Specified by:
processAction in interface javax.portlet.Portlet
Overrides:
processAction in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

doDispatch

protected void doDispatch(javax.portlet.RenderRequest request,
                          javax.portlet.RenderResponse response)
                   throws javax.portlet.PortletException,
                          IOException
Overrides:
doDispatch in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

serveResource

public void serveResource(javax.portlet.ResourceRequest request,
                          javax.portlet.ResourceResponse response)
                   throws javax.portlet.PortletException,
                          IOException
Specified by:
serveResource in interface javax.portlet.ResourceServingPortlet
Overrides:
serveResource in class javax.portlet.GenericPortlet
Throws:
javax.portlet.PortletException
IOException

getWidgetsetURL

protected String getWidgetsetURL(String widgetset,
                                 javax.portlet.PortletRequest request)
Returns the URL from which the widgetset is served on the portal.

Parameters:
widgetset -
request -
Returns:

getThemeURI

protected String getThemeURI(String themeName,
                             javax.portlet.PortletRequest request)
Returns the theme URI for the named theme on the portal. Note that this is not the only location referring to the theme URI - also e.g. PortletCommunicationManager uses its own way to access the portlet 2.0 theme resources.

Parameters:
themeName -
request -
Returns:

writeAjaxPage

protected void writeAjaxPage(javax.portlet.RenderRequest request,
                             javax.portlet.RenderResponse response,
                             Window window,
                             Application application)
                      throws IOException,
                             MalformedURLException,
                             javax.portlet.PortletException
Writes the html host page (aka kickstart page) that starts the actual Vaadin application. If one needs to override parts of the portlet HTML contents creation, it is suggested that one overrides one of several submethods including:

Parameters:
request - the portlet request.
response - the portlet response to write to.
window -
application -
Throws:
IOException - if the writing failed due to input/output error.
MalformedURLException - if the application is denied access the persistent data store represented by the given URL.
javax.portlet.PortletException

writeAjaxPageHtmlVaadinScripts

protected void writeAjaxPageHtmlVaadinScripts(javax.portlet.RenderRequest request,
                                              javax.portlet.RenderResponse response,
                                              BufferedWriter writer,
                                              Application application,
                                              String themeName)
                                       throws IOException,
                                              javax.portlet.PortletException
This method writes the scripts to load the widgetset and the themes as well as define Vaadin configuration parameters on the HTML fragment that starts the actual Vaadin application.

Parameters:
request -
response -
writer -
application -
themeName -
Throws:
IOException
javax.portlet.PortletException

writeAjaxPageScriptWidgetset

protected void writeAjaxPageScriptWidgetset(javax.portlet.RenderRequest request,
                                            javax.portlet.RenderResponse response,
                                            BufferedWriter writer)
                                     throws IOException
Writes the script to load the widgetset on the HTML fragment created by the portlet.

Parameters:
request -
response -
writer -
Throws:
IOException

getVaadinConfigurationMap

protected Map<String,String> getVaadinConfigurationMap(javax.portlet.RenderRequest request,
                                                       javax.portlet.RenderResponse response,
                                                       Application application,
                                                       String themeURI)
                                                throws javax.portlet.PortletException
Returns the configuration parameters to pass to the client. To add configuration parameters for the client, override, call the super method and then modify the map. Overriding this method may also require client side changes in ApplicationConnection and ApplicationConfiguration. Note that this method must escape and quote the values when appropriate. The map returned is typically a LinkedHashMap to preserve insertion order, but it is not guaranteed to be one.

Parameters:
request -
response -
application -
themeURI -
Returns:
modifiable Map from parameter name to its full value
Throws:
javax.portlet.PortletException

writeAjaxPageScriptConfigurations

protected void writeAjaxPageScriptConfigurations(javax.portlet.RenderRequest request,
                                                 javax.portlet.RenderResponse response,
                                                 BufferedWriter writer,
                                                 Map<String,String> config)
                                          throws IOException,
                                                 javax.portlet.PortletException
Constructs the Vaadin configuration section for ApplicationConnection and ApplicationConfiguration. Typically this method should not be overridden. Instead, modify getVaadinConfigurationMap(RenderRequest, RenderResponse, Application, String) .

Parameters:
request -
response -
writer -
config -
Throws:
IOException
javax.portlet.PortletException

writeAjaxPageHtmlTheme

protected void writeAjaxPageHtmlTheme(javax.portlet.RenderRequest request,
                                      BufferedWriter writer,
                                      String themeName,
                                      String themeURI,
                                      String portalTheme)
                               throws IOException
Writes the Vaadin theme loading section of the portlet HTML. Loads both the portal theme and the portlet theme in this order, skipping loading of themes that are already loaded (matched by name).

Parameters:
request -
writer -
themeName -
themeURI -
portalTheme -
Throws:
IOException

writeAjaxPageHtmlMainDiv

protected void writeAjaxPageHtmlMainDiv(javax.portlet.RenderRequest request,
                                        javax.portlet.RenderResponse response,
                                        BufferedWriter writer,
                                        String id,
                                        String classNames,
                                        String divStyle)
                                 throws IOException
Method to write the div element into which that actual Vaadin application is rendered.

Override this method if you want to add some custom html around around the div element into which the actual Vaadin application will be rendered.

Parameters:
request -
response -
writer -
id -
classNames -
divStyle -
Throws:
IOException

getNoScriptMessage

protected String getNoScriptMessage()
Returns a message printed for browsers without scripting support or if browsers scripting support is disabled.


getThemeForWindow

protected String getThemeForWindow(javax.portlet.PortletRequest request,
                                   Window window)
Returns the theme for given request/window

Parameters:
request -
window -
Returns:

getApplicationClass

protected abstract Class<? extends Application> getApplicationClass()
                                                             throws ClassNotFoundException
Throws:
ClassNotFoundException

getNewApplication

protected Application getNewApplication(javax.portlet.PortletRequest request)
                                 throws javax.portlet.PortletException
Throws:
javax.portlet.PortletException

getClassLoader

protected ClassLoader getClassLoader()
                              throws javax.portlet.PortletException
Throws:
javax.portlet.PortletException

getSystemMessages

protected Application.SystemMessages getSystemMessages()
Get system messages from the current application class

Returns:

getPortalProperty

protected static String getPortalProperty(String name,
                                          javax.portlet.PortalContext context)
Returns a portal configuration property. Liferay is handled separately as PortalContext.getProperty(String) does not return portal properties from e.g. portal-ext.properties .

Parameters:
name -
context -
Returns:


Copyright © 2000-2010 IT Mill Ltd. All Rights Reserved.