1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | class Airport{ static constraints = { name() iata(maxSize:3) city() state(maxSize:2) country() } String name String iata String city String state String country = "US" String lat String lng String toString(){ "${iata} - ${name}" } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <g:form action="save" method="post" > <div class="dialog"> <table> <tbody> <tr class="prop"> <td valign="top" class="name"><label for="iata">Iata:</label></td> <td valign="top" class="value ${hasErrors(bean:airport,field:'iata','errors')}"> <input type="text" maxlength="3" id="iata" name="iata" value="${fieldValue(bean:airport,field:'iata')}"/> </td> </tr> <tr class="prop"> <td valign="top" class="name"><label for="city">City:</label></td> <td valign="top" class="value ${hasErrors(bean:airport,field:'city','errors')}"> <input type="text" id="city" name="city" value="${fieldValue(bean:airport,field:'city')}"/> </td> </tr> </tbody> </table> </div> <div class="buttons"> <span class="button"><input class="save" type="submit" value="Create" /></span> </div> </g:form> |
1 2 3 4 5 6 7 8 9 10 11 | def save = { def results = geocoderService.geocodeAirport(params.iata) def airport = new Airport(params + results) if(!airport.hasErrors() && airport.save()) { flash.message = "Airport ${airport.id} created" redirect(action:show,id:airport.id) } else { render(view:'create',model:[airport:airport]) } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | <g:form method="post" > <input type="hidden" name="id" value="${airport?.id}" /> <div class="dialog"> <table> <tbody> <tr class="prop"> <td valign="top" class="name"><label for="iata">Iata:</label></td> <td valign="top" class="value ${hasErrors(bean:airport,field:'iata','errors')}"> <input type="text" maxlength="3" id="iata" name="iata" value="${fieldValue(bean:airport,field:'iata')}"/> </td> </tr> <tr class="prop"> <td valign="top" class="name"><label for="city">City:</label></td> <td valign="top" class="value ${hasErrors(bean:airport,field:'city','errors')}"> <input type="text" id="city" name="city" value="${fieldValue(bean:airport,field:'city')}"/> </td> </tr> <tr class="prop"> <td valign="top" class="name">Name:</td> <td valign="top" class="value">${airport.name}</td> </tr> <tr class="prop"> <td valign="top" class="name">State:</td> <td valign="top" class="value">${airport.state}</td> </tr> <tr class="prop"> <td valign="top" class="name">Country:</td> <td valign="top" class="value">${airport.country}</td> </tr> <tr class="prop"> <td valign="top" class="name">Lat:</td> <td valign="top" class="value">${airport.lat}</td> </tr> <tr class="prop"> <td valign="top" class="name">Lng:</td> <td valign="top" class="value">${airport.lng}</td> </tr> </tbody> </table> </div> <div class="buttons"> <span class="button"><g:actionSubmit class="save" value="Update" /></span> <span class="button"> <g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete" /> </span> </div> </g:form> |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |