I know the application that I am going to explain here is very simple. But I want to share my joy, that’s the only reason I am putting it here. Since it is my first application I won’t like use an IDE.
I wanted to create a web application which can do the CRUD operations on Album details. The Album details include name, artist, release, and copies.
- I downloaded the binary ZIP from http://www.grails.org/Download
- Extracted the zip to C:
- Appended C:\grails-1.1.2\bin" to path variable
- Created GRAILS_HOME C:\grails-1.1.2
- I have created a new workspace C:\grails for putting all my Grails application.
Now the platform is ready for me. I have to do only the coding.
- I have created an application inside C:\grails directory. The command is grails create-app AlbumService
- Then moved inside AlbumService app. cd AlbumService
- I have created a controller for my Album Services grails create-controller Album. It created the a controller named AlbumController.groovy inside C:\grails\AlbumService\grails-app\controllers
class AlbumController {
def index = {
render "Grails Hello World
"
}
} - Next I wanted to know whether my service is up or not. So I edited the AlbumController.I put a Grails Hello World inside the controller.
- Now to run the application I executed the command grails run-app from C:\grails\AlbumService
- When I tried the url: http://localhost:8080/AlbumService/album yes the welcome page is ready.
- Now I wanted to create my Album domain class. grails create-domain-class album
- After that I have edited the file Album.groovy inside C:\grails\AlbumService\grails-app\domain as below. Also I have changed the AlbumController groovy to make def scaffold = true
class AlbumController {
def scaffold = true
def index = {
render "Grails Hello World
"
}
}
class Album {
String name
String artist
Date release
Integer copies
static constraints = {
}
} - I have executed the grials run-app again and opened the url: http://localhost:8080/AlbumService/album/list. I could see the application there I was able to perform all the CRUD operations!!!
0 comments:
Post a Comment