Hi Dan,
Below are 3 functions I use in 5 controllers. They do different things
but all have code in common. I only show here the code they have in
common.
<cffunction name="list" access="public" output="false">
<cfargument name="event">
<cfset var localData={}>
<cfset
arguments.event.setValue("bedrijfIterator",beans.bedrijfService.list(userId=beans.sessionService.getUserId(),bedrijfTypeId=arguments.event.getValue('bedrijfTypeId')))>
<!---create urls--->
<cfset
localData.controller=ListFirst(event.getEventHandlerName(),".")>
<cfset
arguments.event.setValue("xeView",arguments.event.linkTo("#localData.controller#.view#arguments.event.getValue('bedrijfTypeTitle')#"))>
<cfset
arguments.event.setValue("xeNew",arguments.event.linkTo("#localData.controller#.new#arguments.event.getValue('bedrijfTypeTitle')#"))>
<cfset
arguments.event.setValue("xeDelete",arguments.event.linkTo("#localData.controller#.delete#arguments.event.getValue('bedrijfTypeTitle')#"))>
</cffunction>
<cffunction name="new" access="public" output="false">
<cfargument name="event">
<cfset var localData={}>
<cfset
arguments.event.setValue("bedrijfBean",beans.bedrijfService.new(arguments.event.getValue('bedrijfTypeId')))>
<cfset arguments.event.setValue("disabled",false)>
<cfset arguments.event.setValue("newBedrijf",true)>
<!---create urls--->
<cfset
localData.controller=ListFirst(event.getEventHandlerName(),".")>
<cfset
arguments.event.setValue("xeSave",arguments.event.linkTo("#localData.controller#.save#arguments.event.getValue('bedrijfTypeTitle')#"))>
</cffunction>
<cffunction name="save" access="public" output="false">
<cfargument name="event">
<cfset
localData.bedrijfTypeId=arguments.event.getValue("bedrijfTypeId")>
<cfset
beans.bedrijfService.save(bedrijfBean=arguments.event.MakeEventBean(beans.bedrijfBean),bedrijfTypeId=arguments.event.getValue("bedrijfTypeId"))>
</cffunction>
I thought of factoring this code out in an advisor and apply that
advisor to the 5 controllers.
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