13 Apr 2013

Building A Grails jQuery Mobile Project

While I've been working on a Grails 2.x and jQuery Mobile project for the past couple of years, it's been a while since I created a new project from scratch. Here's a quick cheat sheet of the steps.

Create the Grails project and install the following plug-ins (note I always use Spring Security in my projects):

grails create-app MyJQMapp
grails install-plugin joda-time
grails install-plugin jquery-mobile
grails install-plugin jquery-mobile-scaffolding
grails install-plugin spring-security

Setup jQuery Mobile scaffolding templates from the plugin:

grails install-mobile-templates --non-interactive

Setup the Spring Security domains (read the simplified Spring Security with Grails post for more info):

grails s2-quickstart org.example User Role

- Create your domains and customize the just created User, Role and UserRole domains.
- Define users and roles in your BootStrap.groovy
- Generate the controller and view scaffolding based on your domains:

grails generate-all "*"

- Test the app to see where we're at:

grails run-app

- Customize the login view to use jQuery Mobile.
- If you want to use MySQL, Yancy Paredes has a good post on configuring Grails 2 to use MySQL.
- Set up the Spring Security URL Mapping in config.groovy

import grails.plugins.springsecurity.SecurityConfigType
...
grails.plugins.springsecurity.securityConfigType = SecurityConfigType.InterceptUrlMap
interceptUrlMap = [
 '/login/**' :['IS_AUTHENTICATED_ANONYMOUSLY'],
 '/**': ['IS_AUTHENTICATED_FULLY'],
 ]

Hopefully this post has gotten you close to creating a quick jQuery Mobile based Grails up.


Tags:
0 comments