swing - Griffon Update Model and View From Controller -


hello new in griffon framework want add login feature in application. follow model,view , controller:

signinmodel.groovy

@artifactproviderfor(griffonmodel) @griffon.transform.validateable class signinmodel {     @bindable string username     @bindable string password static constraints = {     username(blank: false,nullable: false)     password(blank: false, nullable: false) } 

}

signinview.groovy

@artifactproviderfor(griffonview) 

class signinview {

factorybuildersupport builder signinmodel model signincontroller controller void initui() { builder.with {         application{ frame(title: 'login', size: [330, 230],                     show: true,resizable:false,locationrelativeto: null,                     defaultcloseoperation: exit_on_close) {                 panel(constraints: borderlayout.center,                         border: compoundborder([emptyborder(10),titledborder('welcome tracker')])) { tablelayout() {                         tr {                             td {                                 label(text: "username")                             }                             td {                                 textfield(id: "usernametxt", columns: 15, text: bind(target: model, 'username', mutual: true))                             }                         }                         tr{                             td{                                 label(text:"password")                             }                             td{                                 passwordfield(id:"passwordtxt",columns:15,text:bind(target:model,'password',mutual:true))                              }                         }                     }                 } panel(constraints: borderlayout.south) {                     button text: 'login', actionperformed: {                         model?.geterrors()?.clearallerrors()                         controller.signin()                     }                 } }             }         } } } 

}

signincontroller.groovy

@artifactproviderfor(griffoncontroller) 

class signincontroller {

signinmodel model signinview view void signin(){     try { if (model?.validate()) {             println("no error found..")         } else {     println("error found..")         } }catch (exception ex){         println("exception generated:>>>>>>>>>>>>>>"+ex?.getmessage())     } } 

}

i want update signin view if username , password empty error message. able error message in model view not update please me.

@note: have added griffon validation plugin

you must process errors property of validateable (the model instance). property contains list of messages can used display information user, must choose messages, there may many. current code 1 step away has triggered validation; need consume messages , present them in ui.


Comments