Contents
Domain-renderers
Domain-rendering templates handle the display of a domain for a given action.
The template should be named:
- template/domain.gsp for generic domain
template-type renderer (e.g. editor/domain.gsp)
- template/domainClassName.gsp for
a template-type renderer
of a domainClassName domain (e.g. show/User.gsp)
Variables
- domain - the domain class being displayed
- name - the base name used for the HTML field name for each domain property
- value - the value of the domain object
- style - a map indicating how to display various domain fields
- except - a list of properties that should not be displayed.
This parameter should be overridden when the only parameter is specified.
- exceptWhen - a closure that will eliminate some properties from being displayed.
This parameter should be overridden when the only parameter is specified.
- order - a list specifying the order of specific fields.
This parameter should be overridden when the only parameter is specified.
- only - a list specifying the only fields that should be displayed.
The fields should be displayed in the order specified in the list.
Domain iteration
Iteration on the domain fields can be performed using the
<g:eachDomainProperty> tag.
Iterator struct
- prop - a GrailsDomainClassProperty instance.
Note: this may be subject to change in future releases.
- name - the name of the domain property
- value - the value of the domain property
- style - the style to be applied to the domain property
Domain-association renderers
Domain-association rendering templates handle the display of
a given domain association for a given action.
The template should be named:
- template/relationType.gsp for generic
relationType domain relation
template-type renderer
(e.g. editor/one-one.gsp, list/many.gsp, show/one-many.gsp)
- template/relationType_domainClassName.gsp
for a template-type renderer
of a domainClassName domain relationType relation
(e.g. show/one-one_User.gsp, editor/many-many_Authority.gsp,
list/many_Job.gsp)
Variables
- name - the base name used for the HTML field name for each domain property
- prop - the domain property being displayed
- referencedDomain - the domain class referenced by the association.
Useful in many-type associations
- referencedController - the controller referenced by the association.
Useful for creating links to perform an action on the associated object.
- domainReference - the field used to reference back to this object
by the associated domain. Useful in bidirectional associations
when creating an associated object.
- domainId - the id of the domain instance being displayed.
Useful in bidirectional associations when creating an associated
object
- value - the value of the domain object
- constraints - the GORM constraints applied to this property
- style - an attribute-value map indicating how to display this
property
Type renderers
Type rendering templates handle the display of a given class and its
subclasses for a given action.
Variables
- name - the base name used for the HTML field name for each domain property
- type - the type of the data being displayed
- value - the value of the domain object
- constraints - the GORM constraints applied to this object
- style - an attribute-value map indicating how to display this
property
Examples
a many-to-one editor
The following illustrates how the basic many-to-one editor
is implemented in scaffolding/editor/many-one.gsp.
- If a "hidden" style attribute is set to true,
a hidden field is generated
- If a "readonly" style attribute is set to true,
a hidden field is generated, and the value is displayed
- Otherwise, a selector is displayed for the referenced domain
class, using the HTML name name.id
<g:if test="${style?.hidden}"> <input type="hidden" name='${name}.id' value="${value?.id}" /> </g:if> <g:elseif test="${style?.readonly}"> <input type="hidden" name='${name}.id' value="${value?.id}" />${value} </g:elseif> <g:else> <g:select optionKey="id" from="${referencedDomain.list()}" name='${name}.id' value="${value?.id}" /> </g:else>
|