Hey Marc, Thanks for the detailed post. That was helpful to understand what is going on.
I just tried this on my end and it seems to work out ok. See my file: http://pastebin.com/r6ESFeha In the <scaffold object="Post" type="Commit,View" > <broadcasts> <message-listener name="test" /> </broadcasts> </scaffold> I'm aborting in the Controller method test and I do get an abort. You can try one of two things... Firstly, I'd recommend looking at the generated Scaffold.xml and see what is being rendered for that particular event. Mine was located at /config/scaffolds/scaffolds.xml Next, if that wasn't helpful, turn on the Model Glue debugging and see if there is anything in there that is helpful to understanding why the routing is working as it is, and not as you intend... Post back and let me know what you find. I'm not saying there isn't an issue, but I don't yet have something to replicate on my end. DW On Wed, Jan 25, 2012 at 8:17 AM, marc <[email protected]> wrote: > Hi, > > Today I was playing with the scaffolding feature of MG with CF9 Hibernate > ORM. Everything worked well but I didn't get MG to update a record, instead > it kept adding the modified record. It took me a while to find out I had to > add the record's primary key in the editform so that when the form with the > modified data is submit, Hibernate knows it has to update the record > instead of create a new one. > One of the things I tried before this dawned to me was to override the > scaffolds "commit event by doing this: > > <modelglue> > <scaffold object="vrienden" type="delete,edit,list" > event-type="mainLayout" /> > > <scaffold object="vrienden" type="Commit" event-type="mainLayout"> > <broadcasts> > <message name="vrienden.commit" /> > </broadcasts> > <results> > <result do="vrienden.list" /> > </results> > </scaffold> > > </modelglue> > > and including this in my ModelGlue.xml: > > <controllers> > <controller id="vrienden" > type="modelglueapplicationtemplate.controller.vrienden"> > <message-listener message="vrienden.commit" function="commit" > /> > </controller> > </controllers> > > </modelglue> > > (I split up the main ModelGlue.xml file in separate files and include > those with the <include template="/ModelGlueIncludes/xxx.xml" /> tag in > ModelGlue.xml.) > > To see if this worked, I added a <cfdump> in controllers/vrienden.cfc: > > <cffunction name="Commit"> > <cfargument name="event"> > > <cfdump var="#event#"><cfabort> > </cffunction> > > But this dump never showed up upon committing the editform. Instead a new > record was added or, when I found out about the pk, the existing record was > modified. > > When I removed the line > > <scaffold object="vrienden" type="Commit" event-type="mainLayout"> > > and I had an event handler defined in ModelGlue.xml for the event > "vrienden.commit", that got executed fine. > > So resuming it looks like: > > - the scaffold tag will create the event-handlers specified in it's > type attribute or all event-handlers (list,edit,view,commit,delete) when no > type attribute is specified; > - when specifying a subset of event handlers in the <scaffold> type > attribute and issuing a request with the missing event-handler MG returns > an error message that the event handler is not defined (e.g. <scaffold > type="list,edit,delete" ...> and issuing a request to > /?event=vrienden.commit); > - when adding a separate scaffold tag for the missing event, MG > ignores the <broadcast>,<results> or <view> subtags. Instead it behaves as > if the missing tag type was added to the scaffold's type attribute. > E.g. > <scaffold object="vrienden" type="delete,edit,list" > event-type="mainLayout" /> > > <scaffold object="vrienden" type="commit" event-type="mainLayout"> > <broadcasts> > [...] > </scaffold> > > behaves the same as > > <scaffold object="vrienden" type="delete,edit,list,commit" > event-type="mainLayout" /> > > > Changing the value of Coldspring.xml <defaultScaffolds> tag to not include > the "commit" event handler made no difference. Changing the order I > included my ModelGlue.xml files in the main ModelGlue.xml made no > difference either. > > I checked the docs at > http://docs.model-glue.com/wiki/HowTos/HowToUseScaffolds#Scaffolds. Am I > misinterpreting or overlooking something here? > > Thanks, > > Marc > > -- > Model-Glue Sites: > Home Page: http://www.model-glue.com > Documentation: http://docs.model-glue.com > Bug Tracker: http://bugs.model-glue.com > Blog: http://www.model-glue.com/blog > > You received this message because you are subscribed to the Google > Groups "model-glue" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/model-glue?hl=en -- Plutarch - "The mind is not a vessel to be filled but a fire to be kindled." -- Model-Glue Sites: Home Page: http://www.model-glue.com Documentation: http://docs.model-glue.com Bug Tracker: http://bugs.model-glue.com Blog: http://www.model-glue.com/blog You received this message because you are subscribed to the Google Groups "model-glue" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/model-glue?hl=en
