Uncategorized
Using GatewayMethod to extend Model-Glue Unity Scaffolds
Ok, its a Model-Glue day for me. In my last post I talked about starting to work from the code that is generated for us by the Scaffolds in Model-Glue Unity.
In that post I talked about adding a function to your controller to change the query that is used for a scaffolded event. This is just one way to go about this however. I think for most model-glue ‘ers this will be the most familiar way of adding functionality. However now that we are working with Reactor inside MGU it may not be the best way. Reactor is an ORM framework for cf. It is a kind of highbred between the Active Record and DAO design patterns. What that means to us however is that it creates a Gateway object for each of the tables in our database. This gateway object is then responsible for retrieving sets of data (queries) from our database for us. So in my last example the query I wrote would really have belonged in my MemberGateway object. Again this is not really a tutorial on how Reactor works either (what good am I too you anyway :] ) so I direct you to look more into Reactor if you are interested.
But what I do want to show you is how your Model-Glue.xml file will change using this method. As it stands our event-handler broadcasts the the “member.getAlMembers” message and then displays our list of members. It looks something like this.
What we want to do is bring back our “ModelGlue.genericList” message that our scaffold generated. With that back we can add on the “gatewayMethod” argument and specify the function we created on our gateway. Now our broadcast configuration will look like this:
And the only thing that is really different between what we had in the last post is that last line about gatewayMethod. Now Model-Glue will use our method on our gateway to get the data from the members table. And we can use that same function from elsewhere in our application if we require.
Seems like a long way to go, and we ended up so close to where we started. But hey sometimes it takes a bit of work to learn something. Now go forth and build on the code that has been generated for us.
07 Dec 2006 Simeon

(A little lightbulb just turned on above my head) That’s pretty slick. Thanks again for putting this post together!
Thanks Dan, glad I could help give you some ideas.
Thank you so much for this post. I’ve finally been able to remove some query of queries in my display files (yuck!!) and place the code in the proper gateway where it belongs.
I am soooo glad that it helped some folks. Feel free to post other questions as well and I can post about those as well
I know this was not meant to be a MG tutorial, but could you point me to more info on the whole gatewayBean/gatewayMethod thing? Does the gatewayMethod match a message-listener?