Archive for the ‘GFS’ Category

Grails Flex Scaffold – GFSv0.2.2

December 15, 2009

GFSv0.2.2 Released!!

After the success of the last release, Cubika Labs is glad to announce that the new version of GFS in now available. GFSv0.2.2 includes new functionalities and some fixes.

Among important features you will find the spring-security integration, this was the feature most requested by GFS users.

Although other functionalities that we consider vital for a complete integration are still missing, this is an initial approach and the basis to continue working in the new versions.

Some included improvements in this version are:

  • spring-security Integration (we use stark-security)
  • Tabs group (Thank you so much Nicolas Domina)
  • actions into datagrid

If you want report a bug / improvement or vote our Backlog features’ you are welcome to do it in our Jira

See our Confluence for technical documentation

See our SVN if you want to try the code

See new Screencast

In order to explain how this features work, we are going to write some code for a dummy todo-list app


  • Grails 1.1 or major
  • GFSv0.2.2
  • Flex 3.0.0 or major

FLEX_HOME and GRAILS_HOME must be defined as environment variable!!

Domain Model

1 – Create Project and Install Plugin

gfs@gfs $ grails create-app todo-list gfs@todo-list $ grails install-plugin \ [path-plugin]/ #or gfs@todo-list $ grails install-plugin flex-scaffold

2 – Generate User, Role and Task

#Generets User and Role for spring-security integration gfs@todo-list $ grails stark-security-install-full gfs@todo-list $ grails create-domain-class task

3 – Edit User

class User implements UserDetails {

    String name
    String lastName
    String username
    String password
	String email

    static transients = [

    static hasMany = [ roles: Role ]

    //Generates TAB "ADM User" that contains User's tab
    static groupName = "ADM User" 

    // Need to eagerly fetch role relations, because they'll be asked for later
    // by Spring Security when the hibernate session is no longer available
    static mapping = {
      roles lazy:false


    static constraints = {
      //Generate 2 textinput to validate password.

    GrantedAuthority[] getAuthorities() {
        return roles as GrantedAuthority[]

    boolean isAccountNonLocked() {
        return true
    def setAccountNonLocked(boolean nonLocked) {}

    boolean isCredentialsNonExpired() {
        return true
    def setCredentialsNonExpired(boolean nonExpired) {}

    boolean isAccountNonExpired() {
        return true
    def setAccountNonExpired(boolean acctNonExpired) {}

    boolean isEnabled() {
        return true
    def setEnabled(boolean enabled) {}

4 – Edit Role

class Role implements GrantedAuthority {

    String description
    String authority

    // Add your roles here so you can reference them, for instance:
    // static final ADMIN_USER = 'ROLE_ADMIN_USER'

    // This list holds all roles, convenient when you're declaring controller methods
    // that should be available to everybody (see AccessController for instance).  When
    // you add roles to your system, make sure you add them to this list as well.
    static final ALL_ROLES = [  ANONYMOUS ]

    //Generates TAB "ADM User" that contains Role's tab
    static groupName = "ADM User"

    int compareTo(Object o) {
        if (o instanceof Role) {
            return this.authority.compareTo(o.authority)
         return 0

    String toString() {
        return authority

5 – Edit Task

class Task {

	String name
	String description
	Long priority

	//multiselection:true - A Checkbox appears in all rows on the first datagrid column
	//actions:["postpone"] - show an action button (label=postpone) in each row so you can 
	//add bussines logic into postpone method at TaskService
	//You could declare as many actions buttons as you need eg: actions:["postpone","complete"]
	static action = [datagrid:[multiselection:true,actions:["postpone"]]]

    static constraints = {
		priority(widget:"hslider", range:1..10)
		description(minSize:5, maxSize:255)

6 – Add to Config.groovy = true

7 – Edit StarkSecurityConfig.groovy and change:

    authorizations = [
        '/': Role.ALL_ROLES,
        '/js/**': Role.ALL_ROLES,
        '/css/**': Role.ALL_ROLES,
        '/images/**': Role.ALL_ROLES,
        '/j_spring_security_logout': Role.ALL_ROLES


    authorizations = [
        '/**': Role.ALL_ROLES,
        '/js/**': Role.ALL_ROLES,
        '/css/**': Role.ALL_ROLES,
        '/images/**': Role.ALL_ROLES,
        '/j_spring_security_logout': Role.ALL_ROLES

8 – Edit BootStrap.groovy as below

    import org.codehaus.groovy.grails.plugins.starksecurity.PasswordEncoder

	class BootStrap {

	 def init = { servletContext ->

	  if (!User.findByUsername("admin")) {

      def superUser = new User(username: 'admin',
		           password: PasswordEncoder.encode('admin', 'SHA-256', true),name:"admin",lastName:"admin",

	   def role = new Role(authority:"ROLE_USER",description:"Role users")													



	def destroy = {

9 – Generate Flex Artifacts

gfs@todo-list $ grails generate-all-flex role gfs@todo-list $ grails generate-all-flex user gfs@todo-list $ grails generate-all-flex task

10 – Compile Flex and run app

gfs@todo-list $ grails flex-tasks gfs@todo-list $ grails run-app

11 – Access to application

On the login dialog enter the username and password already setted into BootStrap.groovy (admin/admin for this example).


For this version, we are not taking care of roles regarding functionality.

If you used FlexBuilder you must set-define=GFS::security,false to true (“-define=GFS::security,true”) in the Flex Compiler options (flex arguments), this property will show login dialog if is setted to true. By default it’s false and in command-line compiling (grails flex-tasks) this property will be retrieved from Config.groovy ( = [true|false]).

Grail Flex Scaffold – GFSv0.2 – Coming Soon!!

May 31, 2009

We are about to release a new version of GFS. This new release has tons of new features, bug fixes and an improved way to navigate CRUD operations.

Some of the new features for this release are:

– i18n Support. We now support all the languages that Google can translate. GFS builds up the message[_locale].properties files from the configured default language through Google Translator.

– Integrated reporting with DynamicJasper plugin

File Upload  (Image widget and snapshots through webcam)

– Package support

– Inheritance support (Perfrom CRUDs for subclasses)

– generate-all-flex now supports wildcards “*” (see documentation on how to use this feature)

– More widgets  (hslide, vslider, colorpicker, etc..)

We are also currently working on security features by including Spring Security ( to the GFS plugin. Since we had to modify several core classes to support the dynamic assignment of roles to services we still need to do some testing before we can release an alpha version.

You can see a new screencast on

comming soon Dynamic Jasper example screencast!!

You can download and try GFSv0.2-beta from:

or see installation on 

You can also check the code here:

Documentation is also under development. You can check the updated documentation with all the GFSv0.2 new features documentation here:

Please, report any bug on our jira