|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | PROPERTY | CONSTR | METHOD | DETAIL: FIELD | PROPERTY | CONSTR | METHOD |
java.lang.Objectorg.grails.plugin.vaadin.VaadinRequest
class VaadinRequest
An internal construct for mimicking a user's request to display a particular Vaadin 'page'. However note that this is in no way connected with the JavaEE ServletRequest.
The main benefit is that it brings to Vaadin familiar Grails concepts, i.e.: controllers, actions, views, params, models, flash
The intention is that anyone familiar with Grails should have no problem understanding how to put together a Vaadin project, since all the concepts are familiar. In fact, the standard scaffolded Vaadin Controllers are almost identical to the Grails controllers - they do all of the same things. The Vaadin Views actually create the Vaadin layouts and components.
Moreover, by using the controller/action paradigm, we can easily add standard browser-history behaviour, by automatically adding fragments such as '#book/show/15' to the browser URI whenever we call a Vaadin 'request'.
One might think: Vaadin is not a normal web Http Request/Response-type framework, why is it necessary to structure a Vaadin app in terms of 'requests'? The answer is that generally you will still want to identify a particular set of layouts and components as belonging to a particular 'page' or 'screen' of your user interface. E.g. a user's 'profile' screen, or the 'home' screen etc.
With the Vaadin 'request' and 'dispatcher' constructs, you can wire together such 'pages' (consisting of contollers and views) as easily as is currently possible with normal Grails applications.
See Grails g:link for the set of parameters available for a request. Note that this class also supports an 'instance' as a parameter, which is the actual domain instance (as opposed to an id or a set or params). This is one benefit of Vaadin over Grails Requests!
Nested Class Summary | |
---|---|
static enum |
VaadinRequest.Type
The request can be a top-level browser page or error page, or an include within the page. |
Field Summary | |
---|---|
protected String |
action
|
protected Map |
attributes
|
protected String |
controllerName
|
protected boolean |
dispatched
Indicates if this request has been dispatched |
protected boolean |
external
Indicates if this request has been redirected to external |
protected Map |
flash
|
protected Map |
model
|
protected Map |
params
|
protected boolean |
redirected
Indicates if this request has been redirected |
protected VaadinRequest.Type |
type
|
protected def |
uid
For debugging, a unique id for this instance |
protected String |
url
|
protected Object |
view
|
protected boolean |
viewIsName
|
Property Summary | |
---|---|
String |
fragment
This request's fragment equivalent |
def |
log
|
Application |
vaadinApplication
Vaadin Application for this request |
Constructor Summary | |
VaadinRequest(Application application)
Create an empty request |
|
VaadinRequest(Application application, String fragment, VaadinRequest.Type type = Type.PAGE)
Create a request with specified fragment |
|
VaadinRequest(Application application, Map props, VaadinRequest.Type type = Type.PAGE)
Create a request with the specified properties |
Method Summary | |
---|---|
protected void
|
finishRequest(Object resultObj)
Updates the model after dispatching a request to a controller, but before calling the required view. |
static Map
|
fromFragment(String fragment)
Converts the specified fragment into request props - for example '#book/show/15' |
String
|
getAction()
The requested action - for example 'show' |
Map
|
getAttributes()
The request attributes - for example [foo:'bar'] |
String
|
getController()
The requested controller - for example 'book' |
Map
|
getFlash()
The flash message and error - for example [message:"Book 15 created!"] |
String
|
getId()
The id of the domain instance - for example '15' |
Object
|
getInstance()
The domain instance itself - for example Book(15) |
Map
|
getModel()
The request model - for example [bookInstance:bookInstance] |
Map
|
getParams()
The request params - for example [id:15] |
Map
|
getProperties()
Get properties of this request. |
VaadinRequest.Type
|
getType()
If true, this is a browser page request. |
String
|
getUrl()
The external Url - only applies if this request has been redirected to external. |
Object
|
getView()
The requested view - could be Gsp name, Gsp text or any Vaadin Component. |
String
|
getViewFullName()
Gets view uri of this request (minus params), for example book/show. |
boolean
|
isDispatched()
Indicates if this request has been dispatched |
boolean
|
isExternal()
Indicates if this request has been redirected to an external Url |
boolean
|
isRedirected()
Indicates if this request has been redirected |
boolean
|
isViewIsName()
If true, view is a Gsp name. |
void
|
redirect(Map args)
Used by VaadinControllers to redirect the current 'request' to another controller or action. |
void
|
render(Object view)
Used by VaadinControllers to render a particular view. |
void
|
render(String view)
Used by VaadinControllers to render a particular view. |
void
|
render(Component view)
Used by VaadinControllers to render a particular view. |
void
|
render(Map args)
Used by VaadinControllers to render a particular view. |
void
|
setController(Object controller)
The requested controller - for example 'book' |
protected void
|
setId(String id)
Set the id this request - for example '15' |
protected void
|
setInstance(Object instance)
Set the domain instance for this request - for example Book(15) |
protected void
|
setParams(Map params)
Set the params for this request - for example [id:15] |
void
|
setProperties(Map props)
Set properties of this request |
protected void
|
startRequest(VaadinRequest activeRequest, String currentController, String defaultPage)
Initialises this 'request' based on the 'request' that is currently active, and using the specified set of defaults (in case neither this request or the active request have a particular property). |
static String
|
toFragment(Map props)
Converts this 'request' into a URI fragment - for example '#book/show/15' |
String
|
toString()
This request object represented as a string |
VaadinRequest
|
valueOf(String name)
Returns the enum constant of this type with the specified name. |
VaadinRequest[]
|
values()
Returns an array containing the constants of this enum type, in the order they are declared. |
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
protected String action
protected Map attributes
protected String controllerName
protected boolean dispatched
protected boolean external
protected Map flash
protected Map model
protected Map params
protected boolean redirected
protected VaadinRequest.Type type
protected def uid
protected String url
protected Object view
protected boolean viewIsName
Property Detail |
---|
String fragment
def log
Application vaadinApplication
Constructor Detail |
---|
VaadinRequest(Application application)
VaadinRequest(Application application, String fragment, VaadinRequest.Type type = Type.PAGE)
VaadinRequest(Application application, Map props, VaadinRequest.Type type = Type.PAGE)
Method Detail |
---|
protected void finishRequest(Object resultObj)
resultObj
- The new model (if returned by the controller)
static Map fromFragment(String fragment)
fragment
- The URI fragment to convert into request props
String getAction()
Map getAttributes()
String getController()
Map getFlash()
String getId()
Object getInstance()
Map getModel()
Map getParams()
Map getProperties()
VaadinRequest.Type getType()
String getUrl()
Object getView()
String getViewFullName()
Returns null if the view is a Gsp content string, or a Vaadin Component.
Note that if the view name starts with "/" then it is resolved using the root views directory. Otherwise "/vaadin/{controllerName}/" is prepended to the name.
boolean isDispatched()
boolean isExternal()
boolean isRedirected()
boolean isViewIsName()
void redirect(Map args)
See Grails redirect for controllers
args
- E.g. 'controller' or 'action' to redirect to
void render(Object view)
See Grails render for controllers
view
- Either an args map containing view name as 'view', or Gsp content text, or a Vaadin Component.
void render(String view)
See Grails render for controllers
view
- The view content text to render
void render(Component view)
See Grails render for controllers
view
- The Vaadin Component to render
void render(Map args)
See Grails render for controllers
args
- E.g. 'view' to render to, 'model' to use, etc.
void setController(Object controller)
protected void setId(String id)
protected void setInstance(Object instance)
protected void setParams(Map params)
void setProperties(Map props)
props
- New request properties
protected void startRequest(VaadinRequest activeRequest, String currentController, String defaultPage)
This is called by the VaadinDispatcher at the beginning of the dispatch cycle. E.g. one of the things it does is to set the 'controller' for the new request to be the same as the 'controller' of the current active request, if it is not explicitly overridden in the request parameters.
activeRequest
- The current active request (if any)currentController
- The default controller to use if neither this nor the active request have onedefaultPage
- The default page to use if no controller is found in this request or the active request
static String toFragment(Map props)
String toString()
VaadinRequest valueOf(String name)
VaadinRequest[] values()
Groovy Documentation