grails 2.2.2 platform-core-plugin No signature of method event in domain model -


i try out platform-core-1.0 rc5 plugin services events. write service in grails-plugin "listadmin":

package listadmin  class seco_listenservice {      @grails.events.listener(topic='getentriesoflist', namespace='listadmin')     def getentriesoflist(string intnallistname) {         println "seco_listenservice"         def liste alist = liste.findbyinternal_name(intnallistname)         return alist.eintrage.tolist()     } } 

this service should return list dropdown in other grails-plugin called "institutionadmin". want use list of service dropdown of domain-model. should mention use dynamic scaffolding. try call event in domain-model:

package institutionadmin import org.springframework.dao.dataintegrityviolationexception class einrichtung {      long einrichtungs_type     long type_of_conzept     int anzahl_gruppen     int anzahl_kinder_pro_gruppe     string offnungszeiten     static hasmany = [rooms : raum]     static constraints = {         def alist = []         def reply = event(for:"listadmin", topic:"getentriesoflist", data:"einrichtung_type").waitfor()          alist = reply.value.tolist()         einrichtungs_type(inlist: alist)     } } 

if try run application following error:

caused missingmethodexception: no signature of method: institutionadmin.einrichtung.event() applicable argument types: (java.util.linkedhashmap) values: [[for:listadmin, topic:testeventbus]] possible solutions: ident(), every(), every(groovy.lang.closure), count(), get(java.io.serializable), print(java.lang.object)

if call event in controller fine , documentation of plugin describe can call events in domain-models , services... error-method tell me, class don't know event method.

do have configure else?

should call event in way or mistake?

has experiences module?

the event(...) dynamic methods not available on class (static) level.

you can pull grailsevents spring bean , call event() method alternatively. still have bean application context statically though.

you use custom validator instead, can current domain instance parameter, should have event() method injected.

something :

static mylist = [] static constraints = {     einrichtungs_type validator: { value, instance ->         if(!mylist){             // cache first time save/validate domain             // recommend not here though in              // real life scenario             def reply = instance.event('blabla').get()             mylist = reply.value.tolist()         }          return value in mylist     } } 

anyway, in case load list elsewhere (in bootstrap.groovy instance) , use / inject in domain instead of doing in constraints closure.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -