Java Reference
In-Depth Information
40.<td>${fieldValue(bean: bookInstance, field: "price")}</td>
41.
42.<td>${fieldValue(bean: bookInstance, field: "isbn")}</td>
43.
44.</tr>
45.</g:each>
46.</tbody>
47.</table>
48.<div class="pagination">
49.<g:paginate total="${bookInstanceTotal}" />
50.</div>
51.</div>
52.</body>
53.</html>
Line 14 : The <g:link> tag creates a link to the create action of the
BookController .
Line 19 : The <g:if> tag checks for the existence of flash.message that was
stored in the action and, if found, displays it.
Lines 26 to 31 : The <g:sortableColumn> tag is used to provide sorting on our
list view.
Lines 35 to 45 : The <g:each> tag iterates over the bookInstanceList . Each item
in the list is assigned to the bookInstance variable. The body of the <g:each>
tag fills in the table row with the properties of the bookInstance . In the line
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}"> , a Groovy expression is used
to determine the style class of the <tr> , and the fieldValue( ) method is used
to render the value of each Book property.
Line 49 : The <g:paginate> tag displays the pagination controls if there are
enough elements in the list view. The bookInstanceTotal is used from
Listing 7-19, as mentioned earlier.
The Create View
The create view is illustrated in Listing 7-28.
Listing 7-28. create.gsp
1.<%@ page import="bookstore.Book" %>
2.<!DOCTYPE html>
3.<html>
4.<head>
5.<meta name="layout" content="main">
6.<g:set var="entityName" value="${message(code: 'book.label', default: 'Book')}" />
7.<title><g:message code="default.create.label" args="[entityName]" /></title>
8.</head>
9.<body>
10.<a href="#create-book" class="skip" tabindex="-1"><g:message code="default.link.skip.label"
default="Skip to content&hellip;"/></a>
 
Search WWH ::




Custom Search