ScaffoldTags Tag API

Contents

<g:renderDomain>

Renders a domain using customized views. The search path is:

  1. the current view directory;
  2. a view directory for the domain class;
  3. a generic view under the _domain directory.

For each search path, it first searches for the template {template}/{domainClassName}.gsp. If not found, it defaults to the template {template}/domain.gsp

Parameters

  • domain (required) - the domain to be displayed
  • template (required) - the template to be displayed (e.g. show, edit, list)
  • name - the base name used for the HTML field name for each domain property (for use in editor templates)
  • 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 is overridden when the only parameter is specified.
  • exceptWhen - a closure that will eliminate some properties from being displayed. This parameter is overridden when the only parameter is specified.
  • order - a list specifying the order of specific fields. This parameter is overridden when the only parameter is specified.
  • only - a list specifying the only fields that should be displayed. The fields will be displayed in the order specified in the list.

Examples

<g:renderDomain template="describe" domain="${User}" />
<g:renderDomain template="show" domain="${User}" value="${u}" />

<g:eachDomainProperty>

Loops across the properties of a domain. Intended to be used inside of domain display templates invoked by <g:renderDomain>. This tag will take a domain and break it down as specified so as to simplify further rendering operations.

The body of this tag will receive an implicit 'it' variable which has the following structure:

  • prop - a GrailsDomainClassProperty instance to pass to <g:renderProperty>. 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

Parameters

  • domain (required) - the domain to be displayed
  • name - the base name used for the HTML field name for each domain property (for use in editor templates)
  • value - the value of the domain object.
  • style - a map indicating how to display various domain fields. It is a map of field name to the child style map.
  • except - a list of properties that should not be displayed. This parameter is overridden when the only parameter is specified.
  • exceptWhen - a closure that will eliminate some properties from being displayed. This parameter is overridden when the only parameter is specified.
  • order - a list specifying the order of specific fields. This parameter is overridden when the only parameter is specified.
  • only - a list specifying the only fields that should be displayed. The fields will be displayed in the order specified in the list.

Examples

<g:eachDomainProperty domain="User">${it.descriptor.name}</g:eachDomainProperty>

<g:eachDomainProperty domain="User" value="${u}" except="${it.name = 'password'}">
${it.prop.name}: ${it.value}
</g:eachDomainProperty>

<g:eachDomainProperty domain="User" value="${u}" except="${it.name = 'password'}">
<g:renderProperty prop="${it.prop}" />
</g:eachDomainProperty>

<g:renderProperty>

Renders a domain property using customized views. The search path is:

  1. the current view directory;
  2. a view directory for the domain class;
  3. a generic view under the _domain directory.

For each search path, it first searches for the template {template}/{domain}.{propertyName}.gsp. If not found, it invokes either <g:renderRelation> or <g:renderType>.

Intended to be used inside of domain display templates invoked by <g:renderDomain>.

Parameters

  • template (required) - the template to be displayed (e.g. show, edit, list)
  • prop (required) - the property to be displayed
  • domain - the domain to be displayed
  • name - the base name used for the HTML field name for each domain property (for use in editor templates)
  • value - the value of the domain object
  • style - a map indicating how to display various domain fields
  • domainId - id of the containing domain instance. Used where a controller action link to create an associated object is displayed.

Examples

<g:renderProperty template="describe" domain="${User}" prop="${p}" />
<g:renderProperty template="show" domain="${User}" prop="${p}" value="${u}" />

<g:renderRelation>

Renders a domain relation property using customized views. The search path is:

  1. the current view directory;
  2. a view directory for the domain class;
  3. a generic view under the _domain directory.

For each search path, it searches for templates in the following order:

  1. {template}/${relation}_{type}.gsp
  2. {template}/${relation}.gsp
where relation is:
  • for one-to-one relationships: "one-one", defaulting to "one"
  • for one-to-many relationships: "one-many", defaulting to "many"
  • for many-to-one relationships: "many-one", defaulting to "one"
  • for many-to-many relationships: "many-many", defaulting to "many"
and type is the best-matching class found (using the class inheritance chain). Note: currently this doesn't support interface-based templates

Intended to be used inside of domain display templates invoked by <g:renderDomain>.

Parameters

  • template (required) - the template to be displayed (e.g. show, edit, list)
  • prop (required) - the property to be displayed
  • domain - the domain to be displayed
  • name - the base name used for the HTML field name for each domain property (for use in editor templates)
  • value - the value of the domain object
  • style - a map indicating how to display various domain fields
  • domainId - id of the containing domain instance. Used where a controller action link to create an associated object is displayed.

Examples

<g:renderRelation template="edit" domain="${User}" prop="${p}" />
<g:renderRelation template="show" domain="${User}" prop="${p}" value="${u}" />

<g:eachProperty>

Loops across the properties of a bean. Intended to be used inside of bean display templates invoked by <g:renderType> when the "embedded" widget style is used. This tag will take a bean and break it down as specified so as to simplify further rendering operations.

The body of this tag will receive an implicit 'it' variable which has the following structure:

  • prop - a groovy.lang.MetaClassProperty object. Note: this may be subject to change in future releases.
  • name - the name of the bean property
  • value - the value of the bean property
  • style - the style to be applied to the property

Parameters

  • type (required) - the type of the bean to be displayed
  • name - the base name used for the HTML field name for each property (for use in editor templates)
  • value - the bean to display.
  • style - a map indicating how to display various bean properties. It is a map of field name to the child style map.
  • except - a list of properties that should not be displayed. This parameter is overridden when the only parameter is specified.
  • exceptWhen - a closure that will eliminate some properties from being displayed. This parameter is overridden when the only parameter is specified.
  • order - a list specifying the order of specific fields. This parameter is overridden when the only parameter is specified.
  • only - a list specifying the only fields that should be displayed. The fields will be displayed in the order specified in the list.

Examples

<g:eachProperty type="MyBean">${it.descriptor.name}</g:eachProperty>

<g:eachProperty type="MyBean" value="${beanie}" except="${it.name == 'hiddenStuff'}">
${it.prop.name}: ${it.value}
</g:eachProperty>

<g:eachProperty type="MyBean" value="${beanie}" except="${it.type == Integer.class}">
<g:renderType value="${it.value}" />
</g:eachProperty>

<g:renderType>

Renders a data type using customized views. The search path is:

  1. the current view directory;
  2. a view directory for the domain class;
  3. a generic view under the _domain directory.

For each search path, it searches for {template}/{type}.gsp where type is the best-matching class found (using the class inheritance chain), prefixed with "array_" for array values (not to be confused with lists). Note: If a matching class is not found, but an interface explicitly declared as implemented by that class is found, then that interface is rendered. This interface-matching occurs for each level in the inheritance hierarchy that is examined.

Intended to either be used inside of domain display templates invoked by <g:renderDomain>, or as an independent means to display beans.

Parameters

  • template (required) - the template to be displayed (e.g. show, edit, list)
  • type (required, unless value is non-null) - the class of the property to be displayed
  • domain - the domain to be displayed
  • name - the base name used for the HTML field name for each domain property (for use in editor templates)
  • value - the value of the domain object
  • constraints - constraints as specified in GORM
  • style - a map indicating how to display various domain fields

Examples

<g:renderType template="edit" domain="MyBean" value="${beanie}" />
<g:renderType template="show" domain="${MyBean.class}" value="${beanie}" />

<g:renderActions>

A convenience tag for rendering several domain action links using <g:renderAction>

Intended to be used inside of domain display templates invoked by <g:renderDomain>.

Parameters

  • template (required) - the template to be displayed (e.g. show, edit, list)
  • actions (required) - an array of maps from actions to labels (e.g. [[show: 'Show'], [edit: 'Edit']])
  • controller - the controller upon which the action should be applied
  • item - the item to which the action applies (normally becomes the id parameter)
  • constraints - constraints as specified in GORM
  • widget - a widget style, when multiple action renderers are desired. Works the same as in other tags
  • style - a style map

Examples

<g:renderActions template="list" actions="[[show:'Show'], [edit: 'Edit']]" item="${item}" />

<g:renderAction>

Renders a domain action link using customized renderers. The search path is:

  1. the current view directory;
  2. a view directory for the domain class;
  3. a generic view under the _domain directory.

For each search path, it searches for {template}/action.gsp

Intended to be used inside of domain display templates invoked by <g:renderDomain>.

Parameters

  • template (required) - the template to be displayed (e.g. show, edit, list)
  • action (required) - the action to link (e.g. save, delete, edit)
  • label - the label to use on the action
  • controller - the controller upon which the action should be applied
  • item - the item to which the action applies (normally becomes the id parameter)
  • constraints - constraints as specified in GORM
  • widget - a widget style, when multiple action renderers are desired. Works the same as in other tags
  • style - a style map

Examples

<g:renderAction template="list" action="edit" label="Edit" item="${item}" />

  Sign in   Recent Site Activity   Terms   Report Abuse   Print page  |  Powered by Google Sites