Question

I've created new Groffin module using IntelliJ. I was prompted for create-app command. Creating a module was fine, and as you know, by default, when you ran an app, it shows applet with default content "Content goes here".

Next, I've added a second login MVC group in Application.groovy:

application {
    title = 'Soms'
    startupGroups = ['login']

    // Should Griffon exit when no Griffon created frames are showing?
    autoShutdown = true

    // If you want some non-standard application class, apply it here
    //frameClass = 'javax.swing.JFrame'
}
mvcGroups {
    // MVC Group for "soms"
    'soms' {
        model      = 'soms.SomsModel'
        view       = 'soms.SomsView'
        controller = 'soms.SomsController'
    }

    // MVC Group for "login"
    'login' {
        model       = 'soms.LoginModel'
        view        = 'soms.LoginView'
        controller  = 'soms.LoginController'
    }

}

I've also created:

  1. LoginModel.groovy (groovy class)
  2. LoginController.groovy (groovy class)
  3. LoginView.groovy (groovy script)

in the corresponding folders.

When I run project, it's giving errors:

Base Directory: D:\work\griffon\soms Running script C:\Griffon-1.2.0\scripts\RunApp.groovy Resolving dependencies... Dependencies resolved in 633ms. Environment set to development Resolving framework plugin dependencies ... Framework plugin dependencies resolved in 1114 ms. Resolving plugin dependencies ... Plugin dependencies resolved in 741 ms. [griffonc] Compiling 1 source file to d:\Users\akarasaev.griffon\1.2.0\projects\soms\classes\main Launching application ... 2013-04-15 10:26:44,788 [main] INFO griffon.swing.SwingApplication - Initializing all startup groups: [login] 2013-04-15 10:26:46,311 [AWT-EventQueue-0] ERROR org.codehaus.griffon.runtime.builder.UberBuilder - An error occurred while building soms.LoginView@34a083f2 groovy.lang.MissingPropertyException: No such property: CENTER for class: org.codehaus.griffon.runtime.builder.UberBuilder at org.codehaus.griffon.runtime.builder.UberBuilder.getProperty(UberBuilder.groovy:187) at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.getProperty(UberInterceptorMetaClass.groovy:210) at soms.LoginView.run(LoginView.groovy:18) at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:152) at org.codehaus.griffon.runtime.builder.UberBuilder.build(UberBuilder.groovy:160) at org.codehaus.griffon.runtime.core.AbstractMVCGroup$1.run(AbstractMVCGroup.java:129) 2013-04-15 10:26:46,324 [main] ERROR griffon.util.GriffonExceptionHandler - Uncaught Exception groovy.lang.MissingPropertyException: No such property: CENTER for class: org.codehaus.griffon.runtime.builder.UberBuilder at org.codehaus.griffon.runtime.builder.UberBuilder.getProperty(UberBuilder.groovy:187) at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.getProperty(UberInterceptorMetaClass.groovy:210) at soms.LoginView.run(LoginView.groovy:18) at org.codehaus.griffon.runtime.builder.UberInterceptorMetaClass.invokeMethod(UberInterceptorMetaClass.groovy:152) at org.codehaus.griffon.runtime.builder.UberBuilder.build(UberBuilder.groovy:160) at org.codehaus.griffon.runtime.core.AbstractMVCGroup$1.run(AbstractMVCGroup.java:129)

The same error happens when I try to run from command prompt.

Environment:

  1. Win 7 Pro, 64-bit
  2. IntelliJ IDEA ver 12.1
  3. Griffon-1.2.0 JDK 1.6

LoginModel.groovy:

package soms

import groovy.beans.Bindable
import griffon.transform.PropertyListener
import static griffon.util.GriffonNameUtils.isBlank

@Bindable
@PropertyListener(enabler)
class LoginModel {
    String login
    String password
    boolean submitEnabled
    boolean resetEnabled

    private enabler = { e ->
        submitEnabled = !isBlank(login) && !isBlank(password)
        resetEnabled =  !isBlank(login) || !isBlank(password)
    }
}

LoginView.groovy:

package soms

application(title: 'Login',
        preferredSize: [320, 240],
        pack: true,
        locationByPlatform: true
)

borderLayout()
panel(constraints: CENTER, border: emptyBorder(6)) {
    gridLayout(rows:3, columns:2, hgap:6, vgap:6)

    label: 'login:'
    textField columns: 20, text: bind(target: model, 'login', mutual: true)

    label: 'password:'
    textField columns: 20, text: bind(target: model, 'password', mutual: true)
}

panel(constraints: SOUTH){
    gridLayout(rows:1, cols:2, hgap:6, vgap:6 )
    button('reset', actionPerformed: controller.reset, enabled: bind{model.resetEnabled})
    button('submit', actionPerformed: controller.reset, enabled: bind{model.submitEnabled})
}

LoginController.groovy:

package soms

class LoginController {
    def model
    def view
}
Was it helpful?

Solution

I found out that my LoginController.groovy was incomplete. Now it's working and the correct LoginController.groovy as follows:

package soms

import griffon.transform.Threading

class LoginController {
    def model
    def view

    @Threading(Threading.Policy.SKIP)
    def reset = {
        model.login = ''
        model.password = ''
    }
    def submit = {
        println "Login: ${model.login}"
        println "Password: ${model.password}"
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top