Java Reference
In-Depth Information
43.<g:if test="${bookInstance?.isbn}">
44.<li class="fieldcontain">
45.<span id="isbn-label" class="property-label"><g:message code="book.isbn.label"
default="Isbn" /></span>
46.
47.<span class="property-value" aria-labelledby="isbn-label"><g:fieldValue bean="${bookInstance}"
field="isbn"/></span>
48.
49.</li>
50.</g:if>
51.
52.</ol>
53.<g:form>
54.<fieldset class="buttons">
55.<g:hiddenField name="id" value="${bookInstance?.id}" />
56.<g:link class="edit" action="edit" id="${bookInstance?.id}"><g:message
code="default.button.edit.label" default="Edit" /></g:link>
57.<g:actionSubmit class="delete" action="delete" value="${message(code:
'default.button.delete.label', default: 'Delete')}" onclick="return
confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" />
58.</fieldset>
59.</g:form>
60.</div>
61.</body>
62.</html>
Lines 55 to 56 : The ? after the bookInstance reference is a safe navigation
operator. When this expression is evaluated and if bookInstance is null, the
whole expression evaluates to null, and no exception is thrown.
Line 57 : The <g:actionSubmit> tag generates a submit button that maps to a
specific action, which lets you have multiple submit buttons in a single form.
JavaScript event handlers can be added using the same parameter names as in
HTML.
The Edit View
The edit view is illustrated in Listing 7-30.
Listing 7-30. edit.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.edit.label" args="[entityName]" /></title>
8.</head>
 
Search WWH ::




Custom Search