Groovy Documentation

org.grails.plugin.vaadin
[Groovy] Class VaadinDispatcher

java.lang.Object
  org.grails.plugin.vaadin.VaadinDispatcher
All Implemented Interfaces:
java.io.Serializable

class VaadinDispatcher

Wires VaadinControllers to GSP views using the concept of a VaadinRequest.

Note that a VaadinRequest is not a JavaEE ServletRequest. It is simply a construct for capturing a (user's) request to display a given Vaadin 'page'. See the VaadinRequest javadocs for more details.

This class also automatically listens to changes to browser URI fragments. The listening is started either by explicitly calling startFragmentListener or else it is started automatically after the first 'request' is dispatched.

Authors:
Francis McKenzie
See Also:
VaadinRequest


Field Summary
protected String currentController

Controller of most recent browser page

protected String currentPage

Most recent browser page

protected boolean fragmentListenerStarted

Ensures we only start fragment utility once

protected UriFragmentUtility fragmentUtility

Fragment utility for responding to browser fragment changes

protected boolean stopped

If true, the dispatcher is stopped and will not send requests to controllers

 
Property Summary
static String defaultController

The default controller to use if no controller specified

static String defaultPage

The default page to use if no controller and action specified

def log

Application vaadinApplication

Vaadin Application for this dispatcher

 
Constructor Summary
VaadinDispatcher(Application application)

Create a dispatcher for the specified VaadinApplication.

 
Method Summary
protected void attachPage(Component page)

Adds the specified component as the main window's top-level page component.

def dispatch(String fragment)

Dispatches a 'request' to show a particular Vaadin 'page' using the specified URI fragment, for example '#book/show/15'

def dispatch(Map requestArgs)

Dispatches a 'request' to show a particular Vaadin 'page' using the specified args, containing 'controller', 'action', 'id' etc.

protected def dispatch(VaadinRequest request)

Dispatches a 'request' to show a particular Vaadin 'page' using the specified {@org.grails.plugin.vaadin.VaadinRequest}.

void error(Throwable t, String fragment = null)

Dispatches to the error page for the specified error

protected Component executeRequest(VaadinRequest request, org.codehaus.groovy.grails.commons.GrailsApplication grailsApplication, boolean attach = false)

Executes the controller and view (if not redirected) for specified request.

protected UriFragmentUtility getOrCreateFragmentUtility()

Delay creation of fragment utility until first called.

boolean getStopped()

If true, the dispatcher is stopped and will not send requests to controllers

def refresh()

Dispatches the active page request again, or goes to home page if no active page

protected String renderDefaultErrorHTML(Throwable exception)

Component request(String fragment)

Executes a new request using the specified using the specified URI fragment, and returns the generated view Vaadin Component.

Component request(Map requestArgs)

Executes a new request using the specified args, and returns the generated view Vaadin Component.

protected Component request(VaadinRequest request, boolean attach = false)

Executes the specified {@org.grails.plugin.vaadin.VaadinRequest}, and returns the generated view Vaadin Component.

void start()

Starts the dispatcher

def startFragmentListener()

Listens for changes to browser fragment, and dispatches requests to vaadin controllers.

void stop()

Stops the dispatcher

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

currentController

protected String currentController
Controller of most recent browser page


currentPage

protected String currentPage
Most recent browser page


fragmentListenerStarted

protected boolean fragmentListenerStarted
Ensures we only start fragment utility once


fragmentUtility

protected UriFragmentUtility fragmentUtility
Fragment utility for responding to browser fragment changes


stopped

protected boolean stopped
If true, the dispatcher is stopped and will not send requests to controllers


 
Property Detail

defaultController

static String defaultController
The default controller to use if no controller specified


defaultPage

static String defaultPage
The default page to use if no controller and action specified


log

def log


vaadinApplication

Application vaadinApplication
Vaadin Application for this dispatcher


 
Constructor Detail

VaadinDispatcher

VaadinDispatcher(Application application)
Create a dispatcher for the specified VaadinApplication.
Parameters:
application - The Vaadin Application for this dispatcher


 
Method Detail

attachPage

protected void attachPage(Component page)
Adds the specified component as the main window's top-level page component.


dispatch

def dispatch(String fragment)
Dispatches a 'request' to show a particular Vaadin 'page' using the specified URI fragment, for example '#book/show/15'
Parameters:
fragment - The URI fragment


dispatch

def dispatch(Map requestArgs)
Dispatches a 'request' to show a particular Vaadin 'page' using the specified args, containing 'controller', 'action', 'id' etc.

Attaches the result to the application's main window, and updates the browser fragment.

If a valid request, it is set as the active page request, so that all future requests will be executed relative to this request.

Parameters:
requestArgs - The args containing the details of the request


dispatch

protected def dispatch(VaadinRequest request)
Dispatches a 'request' to show a particular Vaadin 'page' using the specified {@org.grails.plugin.vaadin.VaadinRequest}.

Attaches the result to the application's main window, and updates the browser fragment.

If a valid request, it is set as the active request, so that all future requests will be executed relative to this request.

Parameters:
request - The 'request' containing e.g. the 'controller' etc.


error

void error(Throwable t, String fragment = null)
Dispatches to the error page for the specified error
Parameters:
t - The error


executeRequest

protected Component executeRequest(VaadinRequest request, org.codehaus.groovy.grails.commons.GrailsApplication grailsApplication, boolean attach = false)
Executes the controller and view (if not redirected) for specified request.
Parameters:
request - The request to execute
grailsApplication - The grailsApplication that holds the controllers
attach - If true, the component will be attached to the application's mainWindow before being returned


getOrCreateFragmentUtility

protected UriFragmentUtility getOrCreateFragmentUtility()
Delay creation of fragment utility until first called.

Allows the user to create the mainWindow first.


getStopped

boolean getStopped()
If true, the dispatcher is stopped and will not send requests to controllers


refresh

def refresh()
Dispatches the active page request again, or goes to home page if no active page


renderDefaultErrorHTML

protected String renderDefaultErrorHTML(Throwable exception)


request

Component request(String fragment)
Executes a new request using the specified using the specified URI fragment, and returns the generated view Vaadin Component.
Parameters:
fragment - The URI fragment


request

Component request(Map requestArgs)
Executes a new request using the specified args, and returns the generated view Vaadin Component.
Parameters:
requestArgs - The args containing the details of the request


request

protected Component request(VaadinRequest request, boolean attach = false)
Executes the specified {@org.grails.plugin.vaadin.VaadinRequest}, and returns the generated view Vaadin Component.
Parameters:
request - The 'request' containing e.g. the 'controller' etc.
attach - If true, the component will be attached to the application's mainWindow before being returned


start

void start()
Starts the dispatcher


startFragmentListener

def startFragmentListener()
Listens for changes to browser fragment, and dispatches requests to vaadin controllers.

If no request has been dispatched yet, this dispatches a request to the home page.


stop

void stop()
Stops the dispatcher


 

Groovy Documentation