Geertjan's Blog

  • September 17, 2008

Further Experiments with Griffon

Geertjan Wielenga
Product Manager
Another small experiment with Griffon, but this time there's a problem, one that I've had a couple of times. First, the code.
Here's the model:

import groovy.beans.Bindable
class App1Model {
@Bindable String name = "James"

Here's the controller:

class App1Controller {
def model
def view
def saveName = { evt ->
model.name = view.nameField.text

Here's the view:

application(title: 'App1', size:[320,480],
location:[50,50], pack:true, locationByPlatform:true) {
panel(border:emptyBorder(6)) {
hbox(constraints:NORTH) {
button(action: saveName)
hbox(constraints:SOUTH) {
label(text: "Hello ")
label(text: bind{model.name})

And here's the "App1Actions" that's referred to above:

actions {
action( id: 'saveName',
name: "Save",
closure: controller.saveName,
accelerator: shortcut('S'),
mnemonic: 'S',
shortDescription: "Save the entered name",

Couldn't be much simpler than that. The text in the label is bound to the domain 'name', which changes when the Save button is clicked. I then deployed both the Swing application and the applet (which, for fun, I dragged out of the browser):

But there's a problem. The Swing application works as expected. But the applet only works the first time the Save button is clicked, after that not at all. Possibly there's a threading issue? Or an initialization issue? I didn't use any of the lifecycle classes. Maybe that's why? Anyway, I'm stumped.

Join the discussion

Comments ( 2 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.