Java Reference
In-Depth Information
11.<div class="nav" role="navigation">
12.<ul>
13.<li><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></li>
14.<li><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" />
</g:link></li>
15.</ul>
16.</div>
17.<div id="create-book" class="content scaffold-create" role="main">
18.<h1><g:message code="default.create.label" args="[entityName]" /></h1>
19.<g:if test="${flash.message}">
20.<div class="message" role="status">${flash.message}</div>
21.</g:if>
22.<g:hasErrors bean="${bookInstance}">
23.<ul class="errors" role="alert">
24.<g:eachError bean="${bookInstance}" var="error">
25.<li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id=
"${error.field}"</g:if>><g:message error="${error}"/></li>
26.</g:eachError>
27.</ul>
28.</g:hasErrors>
29.<g:form action="save" >
30.<fieldset class="form">
31.<g:render template="form"/>
32.</fieldset>
33.<fieldset class="buttons">
34.<g:submitButton name="create" class="save" value="${message(code:
'default.button.create.label', default: 'Create')}" />
35.</fieldset>
36.</g:form>
37.</div>
38.</body>
39.</html>
Lines 22 to 28 : The <g:hasErrors> tag examines the Book instance assigned to
its bean attribute and renders its body if errors are found.
Line 29 to 36 : The <g:form> tag sets up an HTML form. This tag has an action
that will result in the URL to submit the form to.
Line 31 : <g:render > applies a built-in or user-defined Groovy template against
a model so that templates can be shared and reused. The template in this case
is called form and is located in the views directory as _form.gsp . The leading
underline denotes that the .gsp file is a template.
The Show View
The show view is illustrated in Listing 7-29.
 
Search WWH ::




Custom Search