`
sillycat
  • 浏览: 2552097 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Grails(11)Guide Book Chapter 11 Internationalization

 
阅读更多
Grails(11)Guide Book Chapter 11 Internationalization
11 Internationalization
grails also leverage the underlying Spring MVC internationalization support.

12 Security

12.4 Security Plugins
12.4.1 Spring Security

12.4.2 Shiro

13 Plugins
13.1 Creating and Installing Plugins
Creating Plugins
Creating a Grails plugin is a simple matter of running the command>
>grails create-plugin [PLUGIN NAME]

This is to create a plugin project

Installing and Distributing Plugins
To distribute a plugin you navigate to its root directory in a console and run
>grails package-plugin
This will create a zip file of the plugin starting with grails-then the plugin name and version.

Install the plugin from a local file
>grails install-plugin /path/to/grails-example-0.1.zip

Or we can install the plugin from remote server
>grails install-plugin http://server.com/plugins/grails-example-0.1.zip

13.2 Plugin Repositories

13.3 Understanding a Plugin's Structure
+ grails-app
     + controllers
     + domain
     + taglib
+ lib
+ src
     + java
     + groovy
+ web-app
     + js
     + css

13.4 Providing Basic

13.6 Hooking into Build Events

13.7 Hooking into Runtime Configuration

13.8 Adding Dynamic Methods at Runtime

13.9 Participating in Auto Reload Events

13.10 Understanding Plugin Load Order

14. Web Services
Web services are all about providing a web API onto your web application and are typically implemented in either REST or SOAP.

14.1 REST
REST is very simple and just involves using plain XML or JSON as a communication medium, combined with URL patterns that are 'representational' of the underlying system, and HTTP methods such as GET, PUT, POST and DELETE

URL patterns
static mappings = {
     "/product/$id?"(resource: "product")
}

GET           show
PUT           update
POST         save
DELETE     delete

We can alter how HTTP methods are handled by using URL Mappings to map to HTTP methods:
"/product/$id"(controller: "product") {
     action = [GET: "show", PUT: "update", DELETE: "delete", POST: "save"]
}

HTTP Methods

XML Marshalling - Reading

import grails.converters.XML

class ProductController {
     def show(){
          if(params.id && Product.exists(params.id)){
               def p = Product.findByName(params.id)
               render p as XML
          }else{
               def all = Product.list()
               render all as XML
          }
     }
}

Data Binding
<?xml version="1.0" encoding="ISO-8859-1" ?>
<product>
     <name>MacBook</name>
     <vendor id="12">
          <name>Apple</name>
     </vendor>
</product>

def save(){
     def p = new Product(params.product)
     if(p.save()){
          render p as XML
     }else {
          render p.errors
     }
}

14.2 SOAP
CXF, Axis2, Metro

14.3 RSS and ATOM

15 Grails and Spring
15.1 The underpinning of Grails is Spring MVC

16. Grails and Hibernate

17. Scaffolding
Scaffolding lets you auto-generate a whole application for a given domain class.
Dynamic Scaffolding
The simplest way to get started with scaffolding is to enable it with the scaffold property. Set the scaffold property in the controller to true for the Book domain class.

class BookController {
     static scaffold = true
}

class SomeController {
     static scaffold = Author
}

Scaffold the controller to domain class Author.

With this configured, when I start my application the actions and views will be auto-generated at runtime. The following actions are dynamically implemented by default by the runtime scaffolding mechanism:
- list
- show
- edit
- delete
- create
- save
- update

A CRUD interface will also be generated. To access this open http://localhost:8080/appName/book

I can add new actions to a scaffolded controller.
class BookController {
     static scaffold = Book
     def changeAuthor(){ …snip… }
}

I can also override the scaffolded actions:
class BookController {
     static scaffold = Book
     //overrides scaffolded action
     def list(){ …snip… }
}

Customizing the Generated Views

Static Scaffolding
>grails generate-controller Book
>grails generate-views Book

>grails generate-all Book     //generate everything

>grails generate-all com.sillycat.Book

18 Deployment
>grails run-app
>grails run-war   // Almost the same as run-app, but the applications are deployed as WAR files, so Hot-reloading is disabled.

WAR file
>grails war


References:
http://grails.org/doc/latest/guide/index.html
http://grails.org/doc/latest/guide/i18n.html
http://grails.org/doc/latest/guide/security.html
http://grails.org/doc/latest/guide/plugins.html
http://grails.org/doc/latest/guide/webServices.html
http://grails.org/doc/latest/guide/spring.html
http://grails.org/doc/latest/guide/hibernate.html
http://grails.org/doc/latest/guide/scaffolding.html
http://grails.org/doc/latest/guide/deployment.html


分享到:
评论

相关推荐

    the definitive guide to grails 2

    《Grails 2 的终极指南》是一本深入探讨Grails框架精髓的专业书籍,该书以英文撰写,旨在为读者提供全面、深入的Grails框架学习资料。Grails框架基于Groovy语言,是一种高度动态、敏捷的Java应用开发框架,它简化了...

    The definitive guide to grails 2 英文版 书 代码

    《The Definitive Guide to Grails 2》是Grails框架深入学习的重要参考资料,由业界专家撰写,旨在为开发者提供全面、详尽的Grails 2技术指导。这本书结合了理论与实践,不仅介绍了Grails的基本概念,还涵盖了高级...

    Grails Grails Grails

    **Grails 框架详解** Grails 是一个基于 Groovy 语言的开源Web应用程序框架,它构建在Java平台之上,旨在简化开发过程并提高生产力。Grails 的设计深受Ruby on Rails的影响,提供了MVC(模型-视图-控制器)架构模式...

    The definate guide to Grails

    《Grails 完全指南》:深入探索 Grails 框架的核心概念与实践 《Grails 完全指南》是 Grails 设计者 Graeme Rocher 和 Jeff Brown 联合编写的经典学习资料,旨在为开发者提供全面、深入的 Grails 框架理解和实践...

    Definitive.Guide.to.Grails

    Definitive Guide to Grails

    The definitive Guide To Grails学习笔记

    《The definitive Guide To Grails学习笔记》是一份深入探讨Grails框架的重要资源,它源于经典书籍《The Definitive Guide to Grails》的精华总结。Grails是一种基于Groovy语言的开源Web应用框架,旨在提高开发效率...

    Grails权威指南 Grails权威指南

    《Grails权威指南》是一本全面深入探讨Grails框架的专著,旨在帮助读者掌握这一强大的Web开发工具。Grails是一种基于Groovy语言的开源框架,它为构建现代、高效的应用程序提供了简洁高效的解决方案。本指南针对不同...

    Eclipse下搭建Grails项目

    【Grails项目搭建详解】 Grails是一个基于Groovy语言的开源Web应用框架,它简化了开发过程,尤其适合快速构建动态网站。在Eclipse中搭建Grails项目可能相对复杂,但通过以下步骤,即使是初学者也能顺利进行。 1. *...

    The definitive guide to grails_2 源代码

    《The Definitive Guide to Grails 2》是关于Grails框架的一本权威指南,它为读者提供了深入理解和使用Grails 2开发Web应用程序所需的知识。Grails是一种基于Groovy语言的开源全栈式Web应用框架,它借鉴了Ruby on ...

    grails-用户手册

    《Grails用户手册》 Grails,作为一个基于Groovy语言的开源Web应用框架,深受开发者喜爱,它简化了Java开发的复杂性,提供了强大的MVC(Model-View-Controller)架构,以及丰富的插件系统。这份用户手册将帮助你...

    Grails技术精解与web开发实践11-20章

    《Grails技术精解与Web开发实践11-20章》是一本专注于Grails框架的深度解析书籍,尤其适合初学者和希望提升Grails开发技能的IT从业者。Grails是一种基于Groovy语言的开源Web应用框架,它以其高效、灵活和强大的特性...

    eclipse开发grails插件

    对于Grails开发,我们需要的是Eclipse中的Grails插件,它能够提供对Grails项目的创建、运行、调试等一系列功能。 **Grails**是基于Groovy语言的全栈式Web开发框架,它借鉴了Ruby on Rails的设计理念,提供了快速...

    The Definitive Guide to Grails 2nd Edition

    The Definitive Guide to Grails 2nd Edition.pdf

    Grails : A Quick-Start Guide

    Java web development is notoriously tedious, ... This book will get you up and running with Grails by putting it to use in constructing an original, working application from start to finish. Book Details

Global site tag (gtag.js) - Google Analytics