First: I'm shocked that I have to ask this question. Nowhere in the docs is it explained how the new "WindowManager" should be used... I've been hacking around some hours around this and I still dont have an satistactionary way of doing something as trivial as this:
def vName = 'Error'
if (!app.views[vName]) { //I just want to create it once, otherwise I'd just change it's model and want to show() it!
buildMVCGroup(vName, vName, errorCode: 500, message: "fail detected ;-)") //ok, this indeed shows the idem (as it's an "frame(/**/show: true,/*...*/", but I dont want to create it each time
}
// app.windowManager.show(app.views.Error) //fails, show() want's an Window, and app.views.Error is of ErrorView type
// app.views.Error.visible = true //won't display the view
// app.views.Error.show() // there is no such method
I'd also need an nice way to hide, something like:
//in controller
def view
def hideAction = {
//view.hide() //fails, no such method...
}
Another way that would make me happy, is an easy way to "when user clicks OK (in the ErrorView", dispose of this MVCGroup. I have been searching and reading the examples quite some time today, yet still can't figure out how to code such easy application flow hmm...
Many thanks in advance for any idea on how to do this, cheers
For frames - what I've done...
In my view I provide a name for the frame
application(name: 'login', ...
Then in my controller I do
app.windowManager.hide(app.windowManager.findWindow('login'))
app.windowManager.show(app.windowManager.findWindow('workspace'))
So... I'm making sure I 'name' all of my views and then I can easily show/hide with the window manager...
Your right about the docs. I'm hoping that what I'm doing is the "right thing to do too".
It is indeed. It makes a call the the setVisible function that is on most JComponents.
show()/hide() are syntactic sugar in Groovy/Griffon that was at one point in J2SE but has been long been deprecated.
Ok, I found quite nice solution for this:
application(/**/){
//...
myError = dialog(/**/){
//thats my error window
}
}
And then in the controller I'd just:
view.myError.visible = true
It's quite elegant for such an thing, hope it's "the right thing to do" :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With