com.vaadin.terminal.gwt.server.
Class AbstractApplicationPortlet
java.lang.Object
javax.portlet.GenericPortlet
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:
- extends javax.portlet.GenericPortlet
- implements Constants
public abstract class AbstractApplicationPortlet
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. |
static String |
WRITE_AJAX_PAGE_SCRIPT_WIDGETSET_SHOULD_WRITE
|
Constructor Summary | |
---|---|
AbstractApplicationPortlet()
|
Method Summary | |
---|---|
protected void |
doDispatch(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response)
|
protected abstract Class<? extends Application> |
getApplicationClass()
|
protected PortletApplicationContext2 |
getApplicationContext(javax.portlet.PortletSession portletSession)
Gets the application context for a PortletSession. |
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(javax.portlet.RenderRequest request)
Returns the URL from which the widgetset is served on the portal. |
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 boolean |
usesDirectWidgetsetLoad(javax.portlet.RenderRequest request)
Checks whether the widgetset should be loaded directly in the generated HTML or indirectly using document.write . |
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. |
protected void |
writeAjaxPageWidgetset(javax.portlet.RenderRequest request,
BufferedWriter writer)
Writes the script to load the widgetset on the HTML fragment created by the portlet if the request attribute "writeAjaxPageScriptWidgetsetShouldWrite" is set to Boolean.TRUE. |
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
- See Also:
- Constant Field Values
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.
WRITE_AJAX_PAGE_SCRIPT_WIDGETSET_SHOULD_WRITE
public static final String WRITE_AJAX_PAGE_SCRIPT_WIDGETSET_SHOULD_WRITE
See Also:
Constructor Detail |
---|
AbstractApplicationPortlet
public AbstractApplicationPortlet()
Method Detail |
---|
init
public void init(javax.portlet.PortletConfig config)
throws javax.portlet.PortletException
- Specified by:
init
in interfacejavax.portlet.Portlet
- Overrides:
init
in classjavax.portlet.GenericPortlet
- Throws:
javax.portlet.PortletException
getApplicationProperty
protected String getApplicationProperty(String parameterName)
- Parameters:
parameterName
- the Name or the parameter.- Returns:
- String value or null if not found
Gets an application property value.
getSystemProperty
protected String getSystemProperty(String parameterName)
- Parameters:
parameterName
- the Name or the parameter.- Returns:
- String value or null if not found
Gets an system property value.
getApplicationOrSystemProperty
protected String getApplicationOrSystemProperty(String parameterName,
String defaultValue)
- Parameters:
parameterName
- the Name or the parameter.defaultValue
- the Default to be used.- Returns:
- String value or default if not found
Gets an application or system property value.
getStaticFilesLocation
protected String getStaticFilesLocation(javax.portlet.PortletRequest request)
- Parameters:
request
-- Returns:
- The location of static resources (inside which there should be a VAADIN directory). Does not end with a slash (/).
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.
getRequestType
protected AbstractApplicationPortlet.RequestType getRequestType(javax.portlet.PortletRequest request)
isProductionMode
public boolean isProductionMode()
- Returns:
- true if in production mode, false if in debug mode
Returns true if the servlet is running in production mode. Production mode disables all debug facilities.
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 interfacejavax.portlet.EventPortlet
- Overrides:
processEvent
in classjavax.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 interfacejavax.portlet.Portlet
- Overrides:
processAction
in classjavax.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 classjavax.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 interfacejavax.portlet.ResourceServingPortlet
- Overrides:
serveResource
in classjavax.portlet.GenericPortlet
- Throws:
javax.portlet.PortletException
IOException
getWidgetsetURL
protected String getWidgetsetURL(javax.portlet.RenderRequest request)
- Parameters:
request
-- Returns:
Returns the URL from which the widgetset is served on the portal.
getWidgetsetURL
protected String getWidgetsetURL(String widgetset,
javax.portlet.PortletRequest request)
- Parameters:
widgetset
-request
-- Returns:
Returns the URL from which the widgetset is served on the portal.
getThemeURI
protected String getThemeURI(String themeName,
javax.portlet.PortletRequest request)
- Parameters:
themeName
-request
-- Returns:
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.
writeAjaxPage
protected void writeAjaxPage(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
Window window,
Application application)
throws IOException,
MalformedURLException,
javax.portlet.PortletException
-
#writeAjaxPageHtmlMainDiv(RenderRequest, RenderResponse, BufferedWriter, String)
-
getVaadinConfigurationMap(RenderRequest, RenderResponse, Application, String)
-
writeAjaxPageHtmlVaadinScripts(RenderRequest, RenderResponse, BufferedWriter, Application, String)
- 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
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:
writeAjaxPageHtmlVaadinScripts
protected void writeAjaxPageHtmlVaadinScripts(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
BufferedWriter writer,
Application application,
String themeName)
throws IOException,
javax.portlet.PortletException
- Parameters:
request
-response
-writer
-application
-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.
writeAjaxPageWidgetset
protected void writeAjaxPageWidgetset(javax.portlet.RenderRequest request,
BufferedWriter writer)
throws IOException
- Parameters:
request
-writer
-- Throws:
IOException
Writes the script to load the widgetset on the HTML fragment created by the portlet if the request attribute "writeAjaxPageScriptWidgetsetShouldWrite" is set to Boolean.TRUE.
Warning! Loading widgetsets in this may cause a race condition in the browser if there are multiple portlets on the same page (see #9774).
This method doesn't do anything unless
usesDirectWidgetsetLoad(RenderRequest)
has been overridden to
return true
.
writeAjaxPageScriptWidgetset
protected void writeAjaxPageScriptWidgetset(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
BufferedWriter writer)
throws IOException
- Parameters:
request
-response
-writer
-- Throws:
IOException
Writes the script to load the widgetset on the HTML fragment created by the portlet.
usesDirectWidgetsetLoad
protected boolean usesDirectWidgetsetLoad(javax.portlet.RenderRequest request)
- Parameters:
request
- the render request for which the widgetset loading method should be determined- Returns:
true
to use direct widgetset loading,false
to use the default indirect widgetset loading.
Checks whether the widgetset should be loaded directly in the generated
HTML or indirectly using document.write
.
In the normal case, indirect loading using document.write
should be used as it ensures that the widgetset is only loaded once on
each page. Usage of document.write
does however cause
problems with GWT Super Dev Mode and various other techniques that depend
on loading scripts in a special order (see #8924). These cases can be
supported by using the direct loading technique instead, even though that
way of loading the widgetset can cause race conditions if a page contains
multiple portlets using the same widgetset (see #9774).
For the default indirect loading,
writeAjaxPageScriptWidgetset(RenderRequest, RenderResponse, BufferedWriter)
is adding the document.write
code. The direct loading
instead uses
writeAjaxPageWidgetset(RenderRequest, BufferedWriter)
to create
HTML that loads the widgetset.
By default, indirect loading is used.
getVaadinConfigurationMap
protected Map<String,String> getVaadinConfigurationMap(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
Application application,
String themeURI)
throws javax.portlet.PortletException
- Parameters:
request
-response
-application
-themeURI
-- Returns:
- modifiable Map from parameter name to its full value
- 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.
writeAjaxPageScriptConfigurations
protected void writeAjaxPageScriptConfigurations(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
BufferedWriter writer,
Map<String,String> config)
throws IOException,
javax.portlet.PortletException
- Parameters:
request
-response
-writer
-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)
.
writeAjaxPageHtmlTheme
protected void writeAjaxPageHtmlTheme(javax.portlet.RenderRequest request,
BufferedWriter writer,
String themeName,
String themeURI,
String portalTheme)
throws IOException
- Parameters:
request
-writer
-themeName
-themeURI
-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).
writeAjaxPageHtmlMainDiv
protected void writeAjaxPageHtmlMainDiv(javax.portlet.RenderRequest request,
javax.portlet.RenderResponse response,
BufferedWriter writer,
String id,
String classNames,
String divStyle)
throws IOException
- Parameters:
request
-response
-writer
-id
-classNames
-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.
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)
- Parameters:
request
-window
-- Returns:
Returns the theme for given request/window
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()
- Returns:
Get system messages from the current application class
getPortalProperty
protected static String getPortalProperty(String name,
javax.portlet.PortalContext context)
- Parameters:
name
-context
-- Returns:
Returns a portal configuration property.
Liferay is handled separately as
PortalContext.getProperty(String)
does not return portal
properties from e.g. portal-ext.properties .
getApplicationContext
protected PortletApplicationContext2 getApplicationContext(javax.portlet.PortletSession portletSession)
- Parameters:
portletSession
- the portlet session.- Returns:
- the application context for the session.
Gets the application context for a PortletSession. If no context is currently stored in a session a new context is created and stored in the session.