Wednesday September 17, 2008
Further Experiments with Griffon
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:
build(App1Actions)
application(title: 'App1', size:[320,480],
location:[50,50], pack:true, locationByPlatform:true) {
panel(border:emptyBorder(6)) {
borderLayout()
hbox(constraints:NORTH) {
label(text:"Name:")
hstrut(5)
textField(id:"nameField",columns:20,"Tom")
hstrut(5)
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.
Sep 17 2008, 02:17:44 PM PDT Permalink
Sounds like a bug we need to look at. The jira bus ssytem for Grifofn is up: http://jira.codehaus.org/browse/GRIFFON so you can have the pleasure of posting the first issue.
Posted by Danno Ferrin on September 17, 2008 at 02:51 PM PDT #
Hurray, the first bug report for Griffon:
http://jira.codehaus.org/browse/GRIFFON-1
Posted by Geertjan on September 18, 2008 at 04:22 AM PDT #


