Groovy Documentation

org.grails.plugin.vaadin.gsp
[Groovy] Class GspComponentNode

java.lang.Object
  org.grails.plugin.vaadin.gsp.GspComponentNode

class GspComponentNode

Holds a Vaadin Component and a tag body, and facilitates adding components & config nested within the tag body to this component.

Authors:
Francis McKenzie


Field Summary
protected boolean isBodyEvaluated

Indicates if evaluateBody() has been run yet or not.

 
Property Summary
Closure body

The tag body that will be evaluated

CharSequence bodyText

The body text that results from evaluating the tag body.

Component component

The Vaadin Component to which the tag body applies

List configs

The collection of config objects that is populated by nested config tags when the tag body is evaluated.

Closure withBody

A closure to run against the result of evaluating the tag body

Closure withConfig

A closure to run against the collection of config objects that result from evaluating the tag body.

 
Constructor Summary
GspComponentNode(Component component, Closure body)

Creates a new node with the specified Vaadin Component and tag body.

GspComponentNode(Component component, Closure body, Closure withBody)

Creates a new node with the specified Vaadin Component, tag body and closure to run against the result of evaluating the tag body.

GspComponentNode(Component component, Closure body, Closure withBody, Closure withConfig)

Creates a new node with the specified Vaadin Component, tag body, and closures to run against the result of evaluating the tag body, and the collection of config objects added during evaluation of the tag body.

 
Method Summary
CharSequence attachComponent(Component child, Map params = null)

Attaches the specified child Vaadin Component to the Vaadin Component stored in this node.

void attachConfig(GspComponentConfig componentConfig)

Adds the specified component config to the collection of component configs held by this node.

protected CharSequence evaluateBody()

Evaluates the tag body, and returns the result.

CharSequence getBodyText()

Gets the text of evaluating the tag body.

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

Field Detail

isBodyEvaluated

protected boolean isBodyEvaluated
Indicates if evaluateBody() has been run yet or not.


 
Property Detail

body

Closure body
The tag body that will be evaluated


bodyText

CharSequence bodyText
The body text that results from evaluating the tag body. (Note this will be null until the first call to evaluateBody())


component

Component component
The Vaadin Component to which the tag body applies


configs

List configs
The collection of config objects that is populated by nested config tags when the tag body is evaluated.


withBody

Closure withBody
A closure to run against the result of evaluating the tag body


withConfig

Closure withConfig
A closure to run against the collection of config objects that result from evaluating the tag body.


 
Constructor Detail

GspComponentNode

GspComponentNode(Component component, Closure body)
Creates a new node with the specified Vaadin Component and tag body.
Parameters:
component - The Vaadin Component to which components in the tag body will be added
body - The tag body that will be evaluated


GspComponentNode

GspComponentNode(Component component, Closure body, Closure withBody)
Creates a new node with the specified Vaadin Component, tag body and closure to run against the result of evaluating the tag body.
Parameters:
component - The Vaadin Component to which components in the tag body will be added
body - The tag body that will be evaluated
withBody - The closure to run against the result of evaluating the tag body


GspComponentNode

GspComponentNode(Component component, Closure body, Closure withBody, Closure withConfig)
Creates a new node with the specified Vaadin Component, tag body, and closures to run against the result of evaluating the tag body, and the collection of config objects added during evaluation of the tag body.
Parameters:
component - The Vaadin Component to which components in the tag body will be added
body - The tag body that will be evaluated
withBody - The closure to run against the result of evaluating the tag body
withConfig - The closure to run against the collection of config objects resulting from evaluating the tag body.


 
Method Detail

attachComponent

CharSequence attachComponent(Component child, Map params = null)
Attaches the specified child Vaadin Component to the Vaadin Component stored in this node.

Note this node's Vaadin Component MUST be of type ComponentContainer

If this node's Vaadin Component is a CustomLayout, then calls addComponent(com.vaadin.ui.Component,java.lang.String) on the component.

Otherwise, it calls addComponent(com.vaadin.ui.Component)

Node that this method can return text, which is then used by other classes such as @{link GspAttacher} to replace the component in the parent tag's body text with some HTML. However, this class always returns null from this method. Subclasses of this class should override this method if they need to return text when adding a child component.

Parameters:
child - The child Vaadin Component to add to this node's container component
params - The (optional) params to use when adding the child component to this node's component. Typically will contain 'location'
Returns:
The text result of adding the child component - always returns null, because this is only useful to subclasses.


attachConfig

void attachConfig(GspComponentConfig componentConfig)
Adds the specified component config to the collection of component configs held by this node. The component configs will be passed to the withConfig closure when the evaluateBody() method is called.

Note the componentClass of the GspComponentConfig must be the same as the class of the Component in this node, otherwise an error will be thrown.

Parameters:
componentConfig - The component config to add this node


evaluateBody

protected CharSequence evaluateBody()
Evaluates the tag body, and returns the result. Also calls the withBody and withConfig closures (if they exist) on the resulting body text and collection of config objects.
Returns:
The text result of executing the tag body


getBodyText

CharSequence getBodyText()
Gets the text of evaluating the tag body. Only evaluates the body the first time this method is called, then stores the result for future calls to this method.
Returns:
The text result of executing the tag body


 

Groovy Documentation