如何在Griffon中轻松显示/隐藏视图

Kon*_*ski 5 groovy griffon

第一:我很震惊,我不得不问这个问题.在文档中没有任何地方它解释了应该如何使用新的"WindowManager"......我已经在这周围几个小时的黑客攻击了,我仍然没有像这样微不足道的做事的satistactionary方式:

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
Run Code Online (Sandbox Code Playgroud)

我还需要一个很好的隐藏方式,例如:

//in controller
def view
def hideAction = {
  //view.hide() //fails, no such method...
}
Run Code Online (Sandbox Code Playgroud)

让我开心的另一种方法是"当用户点击OK(在ErrorView中),处理这个MVCGroup时的一种简单方法.我一直在搜索和阅读这些例子很长一段时间,但仍然无法弄清楚如何编写如此简单的应用程序流程嗯......

非常感谢任何有关如何做到这一点的想法,欢呼

Kon*_*ski 1

好的,我找到了很好的解决方案:

application(/**/){
  //...
  myError = dialog(/**/){
    //thats my error window
  }
}
Run Code Online (Sandbox Code Playgroud)

然后在控制器中我只是:

view.myError.visible = true
Run Code Online (Sandbox Code Playgroud)

对于这样的事情来说,这是相当优雅的,希望这是“正确的事情”:-)