Sorry if this is obvious to others as to how and where to do this, but
are you suggesting that I create the ViewFormatter.cfc component with
my view-altering methods, then load it using a Property.cfc type
object (such as appProperty.cfc) that has a configure method that
calls a (for example) loadProperties method containing setProperty
lines like:
<cfset setProperty('viewFormatter',ViewFormatter.cfc)>
then place this info the mach-ii.xml file...
<properties>
<property name="appProperty"
type="pathToYourApp.property.appProperty" />
</properties>
As for my icon img page definer... my method is passed in a single
argument such as "edit" and returns the string '<img
src="somepath_to_edit_icon">'
So in my view file I can do a ViewFormatter.getIconPath("edit") where
I need that img tag of a pencil to appear.
On Jun 4, 12:53 pm, Adam Ness <[email protected]> wrote:
...
> I would probably suggest creating a CFC named something along the lines of
> "ViewHelper" or "ViewFormatter", and instantiating it on application
> creation using "setProperty".
>
> Then, in your .cfm files in the view, you can just do this:
>
> <cfset formatter = getProperty("viewFormatter") />
>
> <img src="#formatter.getBaseHtmlPath()#images/foo.gif" />
>
> As a general solution for things which really do need to go into the model
> layer, you should try to as narrowly identify which set of objects those
> methods need to be available to, and then either inject a CFC containing
> those functions into the model classes that require it, or subclass your
> model objects which need it from a single model object which holds those
> methods. The first option is generally better, but the second one will also
> work, and might be cleaner in some rare circumstances.
>
> On Thu, Jun 4, 2009 at 11:24 AM, Teaman <[email protected]> wrote:
>
> > Still trying to understand Listeners and went through the very well
> > done Primer on the Mach-II site.
> > But the listeners there are called using one <notify> tag in the
> > config xml file and reference one component such as a gateway. I
> > realize the example was kept simple which I appreciate. Now I'm still
> > in the mode of porting an existing app and trying to figure out where
> > all the code *should* go.
>
> > What if I have a web form in a view and I need to run several queries
> > to produce the pulldown menus (for example) would each require a
> > separate method call to the listener resulting in multiple <notify>
> > tags placed in the same event-handler?
> > If so could each call the same or different listeners?
>
> > What if I have some more global or general type functions I need to
> > run in the model... like one to generate the web root path for the
> > site or determine the path to an icon library of images for a given
> > identifier. Assuming I put these type of functions into a
> > GlobalGateway.cfc, would I instantiate this in the configure method of
> > the listener?
> > Which listener?
> > Any listener?
>
> > The primer example put the component instantiation in a particular
> > method of the listener. Why not put it in the configure? In
> > particular, this makes more sense when more than one method of that
> > listener needs to use the same gateway component... to make function
> > calls in that gateway component.
> > I'm looking for best-practices to get going on the "right foot".
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to Mach-II for CFML list.
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/mach-ii-for-coldfusion?hl=en
SVN: http://greatbiztoolsllc.svn.cvsdude.com/mach-ii/
Wiki / Documentation / Tickets:
http://greatbiztoolsllc.trac.cvsdude.com/mach-ii/
-~----------~----~----~----~------~----~------~--~---