com.vaadin.terminal.gwt.server
Class BootstrapHandler

java.lang.Object
  extended by com.vaadin.terminal.gwt.server.BootstrapHandler
All Implemented Interfaces:
RequestHandler, Serializable

public abstract class BootstrapHandler
extends Object
implements RequestHandler

See Also:
Serialized Form

Nested Class Summary
protected  class BootstrapHandler.BootstrapContext
           
 
Constructor Summary
BootstrapHandler()
           
 
Method Summary
 BootstrapHandler.BootstrapContext createContext(WrappedRequest request, WrappedResponse response, Application application, Integer rootId)
           
 String findAndEscapeThemeName(BootstrapHandler.BootstrapContext context)
          Don not override.
protected  String getApplicationCSSClassName(Application application)
          Returns the application class identifier for use in the application CSS class name in the root DIV.
protected abstract  String getApplicationId(BootstrapHandler.BootstrapContext context)
          Creates and returns a unique ID for the DIV where the application is to be rendered.
protected  JSONObject getApplicationParameters(BootstrapHandler.BootstrapContext context)
           
protected abstract  String getAppUri(BootstrapHandler.BootstrapContext context)
           
protected  JSONObject getDefaultParameters(BootstrapHandler.BootstrapContext context)
           
protected abstract  String getInitialUIDL(WrappedRequest request, Root root)
          Gets the initial UIDL message to send to the client.
protected  String getMainDivStyle(BootstrapHandler.BootstrapContext context)
           
protected  String getNoScriptMessage()
          Returns a message printed for browsers without scripting support or if browsers scripting support is disabled.
 String getThemeName(BootstrapHandler.BootstrapContext context)
          Override if required
 String getThemeUri(BootstrapHandler.BootstrapContext context, String themeName)
          Get the URI for the application theme.
 String getWidgetsetForRoot(BootstrapHandler.BootstrapContext context)
           
 boolean handleRequest(Application application, WrappedRequest request, WrappedResponse response)
          Handles a non-UIDL request.
protected  void setBootstrapPageHeaders(BootstrapHandler.BootstrapContext context)
          Method to set http request headers for the Vaadin kickstart page.
protected  void writeBootstrapPage(WrappedRequest request, WrappedResponse response, Application application, Integer rootId)
           
protected  void writeBootstrapPageHtmlBodyStart(BootstrapHandler.BootstrapContext context)
          Method to open the body tag of the html kickstart page.
protected  void writeBootstrapPageHtmlHeader(BootstrapHandler.BootstrapContext context)
          Method to write the contents of head element in html kickstart page.
protected  void writeBootstrapPageHtmlHeadStart(BootstrapHandler.BootstrapContext context)
          Method to write the beginning of the html page.
protected  void writeBootstrapPageHtmlMainDiv(BootstrapHandler.BootstrapContext context)
          Method to write the div element into which that actual Vaadin application is rendered.
protected  void writeBootstrapPageHtmlVaadinScripts(BootstrapHandler.BootstrapContext context)
          Method to write the script part of the page which loads needed Vaadin scripts and themes.
protected  void writeError(WrappedResponse response, Throwable e)
           
protected  void writeMainScriptTagContents(BootstrapHandler.BootstrapContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BootstrapHandler

public BootstrapHandler()
Method Detail

handleRequest

public boolean handleRequest(Application application,
                             WrappedRequest request,
                             WrappedResponse response)
                      throws IOException
Description copied from interface: RequestHandler
Handles a non-UIDL request. If a response is written, this method should return false to indicate that no more request handlers should be invoked for the request.

Specified by:
handleRequest in interface RequestHandler
Parameters:
application - The application to which the request belongs
request - The request to handle
response - The response object to which a response can be written.
Returns:
true if a response has been written and no further request handlers should be called, otherwise false
Throws:
IOException

writeBootstrapPage

protected final void writeBootstrapPage(WrappedRequest request,
                                        WrappedResponse response,
                                        Application application,
                                        Integer rootId)
                                 throws IOException,
                                        JSONException
Throws:
IOException
JSONException

createContext

public BootstrapHandler.BootstrapContext createContext(WrappedRequest request,
                                                       WrappedResponse response,
                                                       Application application,
                                                       Integer rootId)

getMainDivStyle

protected String getMainDivStyle(BootstrapHandler.BootstrapContext context)

getApplicationId

protected abstract String getApplicationId(BootstrapHandler.BootstrapContext context)
Creates and returns a unique ID for the DIV where the application is to be rendered.

Parameters:
context -
Returns:
the id to use in the DOM

getWidgetsetForRoot

public String getWidgetsetForRoot(BootstrapHandler.BootstrapContext context)

writeBootstrapPageHtmlMainDiv

protected void writeBootstrapPageHtmlMainDiv(BootstrapHandler.BootstrapContext context)
                                      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:
context -
Throws:
IOException

getNoScriptMessage

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


getApplicationCSSClassName

protected String getApplicationCSSClassName(Application application)
Returns the application class identifier for use in the application CSS class name in the root DIV. The application CSS class name is of form "v-app-"+getApplicationCSSClassName(). This method should normally not be overridden.

Returns:
The CSS class name to use in combination with "v-app-".

writeBootstrapPageHtmlBodyStart

protected void writeBootstrapPageHtmlBodyStart(BootstrapHandler.BootstrapContext context)
                                        throws IOException
Method to open the body tag of the html kickstart page.

This method is responsible for closing the head tag and opening the body tag.

Override this method if you want to add some custom html to the page.

Throws:
IOException

writeBootstrapPageHtmlVaadinScripts

protected void writeBootstrapPageHtmlVaadinScripts(BootstrapHandler.BootstrapContext context)
                                            throws IOException,
                                                   JSONException
Method to write the script part of the page which loads needed Vaadin scripts and themes.

Override this method if you want to add some custom html around scripts.

Parameters:
context -
Throws:
IOException
JSONException

writeMainScriptTagContents

protected void writeMainScriptTagContents(BootstrapHandler.BootstrapContext context)
                                   throws JSONException,
                                          IOException
Throws:
JSONException
IOException

getApplicationParameters

protected JSONObject getApplicationParameters(BootstrapHandler.BootstrapContext context)
                                       throws JSONException,
                                              PaintException
Throws:
JSONException
PaintException

getDefaultParameters

protected JSONObject getDefaultParameters(BootstrapHandler.BootstrapContext context)
                                   throws JSONException
Throws:
JSONException

getAppUri

protected abstract String getAppUri(BootstrapHandler.BootstrapContext context)

writeBootstrapPageHtmlHeader

protected void writeBootstrapPageHtmlHeader(BootstrapHandler.BootstrapContext context)
                                     throws IOException
Method to write the contents of head element in html kickstart page.

Override this method if you want to add some custom html to the header of the page.

Throws:
IOException

setBootstrapPageHeaders

protected void setBootstrapPageHeaders(BootstrapHandler.BootstrapContext context)
Method to set http request headers for the Vaadin kickstart page.

Override this method if you need to customize http headers of the page.

Parameters:
context -

writeBootstrapPageHtmlHeadStart

protected void writeBootstrapPageHtmlHeadStart(BootstrapHandler.BootstrapContext context)
                                        throws IOException
Method to write the beginning of the html page.

This method is responsible for writing appropriate doc type declarations and to open html and head tags.

Override this method if you want to add some custom html to the very beginning of the page.

Parameters:
context -
Throws:
IOException

getThemeUri

public String getThemeUri(BootstrapHandler.BootstrapContext context,
                          String themeName)
Get the URI for the application theme. A portal-wide default theme is fetched from the portal shared resource directory (if any), other themes from the portlet.

Parameters:
context -
themeName -
Returns:

getThemeName

public String getThemeName(BootstrapHandler.BootstrapContext context)
Override if required

Parameters:
context -
Returns:

findAndEscapeThemeName

public String findAndEscapeThemeName(BootstrapHandler.BootstrapContext context)
Don not override.

Parameters:
context -
Returns:

writeError

protected void writeError(WrappedResponse response,
                          Throwable e)
                   throws IOException
Throws:
IOException

getInitialUIDL

protected abstract String getInitialUIDL(WrappedRequest request,
                                         Root root)
                                  throws PaintException,
                                         JSONException
Gets the initial UIDL message to send to the client.

Parameters:
request - the originating request
root - the root for which the UIDL should be generated
Returns:
a string with the initial UIDL message
Throws:
PaintException - if an exception occurs while painting the components
JSONException - if an exception occurs while formatting the output


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.