I am trying to re-using templates over multiple domains.
Template looks like this:
<div id="emailEntry">
<Table>
<tr class="prop">
<td valign="top" class="name">
<label for="email" id="email"><g:message code="default.email.label" default="Primary e-mail address* :" id="email" /></label>
</td>
<td valign="top" class="value ${hasErrors(bean: instanceToUse, field: 'email', 'errors')}">
<g:textField name="email" value="${instanceToUse?.email}"/>
</td>
</tr>
</Table>
</div>
and my view calls this template like this:
<g:render template="/templates/frmEmailTableEntry" />
Both of my class “customer” and “employee” have email attributes.
so my question is, if I want to reuse template “frmEmailTableEntry” for class “customer” and “employee“, what should I put to “instanceToUse” in template.
I read about rendering with var declared, but I am not so sure how to pass this. Please help me with this.
Thanks in advance.
It doesn’t really matter what you put in the template. If you leave it just as is you could use it in other gsp’s like this:
That passes the
customerInstanceinto the${instanceToUse}variable in the template.