Building Rich Internet applications using Grails, part 2nd

Source: Internet
Author: User
Tags web services grails

Related articles:

Building Rich Internet applications with Grails, part 1th: Building Web Applications with Grails and Flex

Grails and Google Web Toolkit

Introduction: In part 2nd of this 2-part series, a new service is created based on the WEB service that you created with Grails in part 1th. You will create a new search page, but this time using the Google Web Toolkit (GWT) to create this application. In addition, you will use some of the richer UI widgets in the Ext GWT library.

About this series

This series explores application architectures that use a service-oriented architecture (SOA) implemented by the Grails framework at the back end. Learn how Grails greatly simplifies the creation of Web applications, especially Web services. This backend can be easily connected to any pure client application. In the 1th part, you will use Adobe Flex to create an application that can use Flash Player. In this article, you will create a front-end with pure JavaScript via Google Web Toolkit (GWT).

Prerequisite

In this article, you will build a WEB application using Grails and GWT. The Grails framework is based on the Groovy programming language, which is a dynamic language for the Java™ platform. It's better to be familiar with Groovy, but not necessary. Learning about Java or other dynamic languages, such as Ruby or Python, can be a great help. This article uses Grails 1.0.3. Grails can be used with many databases or application servers, but this article does not need to provide them because they are already shipped with grails. This front-end is built using Google Web Toolkit, and you must be familiar with Java to use GWT. This article is using the Google Web Toolkit 1.5.3.

New service

In the 1th part, you use Grails to create an application that uses Service Oriented architecture (SOA). You can build a new application based on this backend. This is the main advantage of using the back end of the SOA with a pure client front-end. Your server-side code is completely detached from the user interface. However, to further demonstrate how simple it is to create a Web service using Grails, we will modify the existing backend and add a search API to it.

Search API Services

An existing application already has a search business service. We only use its list API to provide a list of all the news in the application. Look at the other features of this service, as shown in Listing 1.

Listing 1. Search Business Services

class SearchService {

   boolean transactional = false

   def list() {
     Story.list()
   }

   def listCategory(catName){
     Story.findAllWhere(category:catName)
   }

   def searchTag(tag){
     Story.findAllByTagsIlike("%"+tag+"%")
   }
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.