Hey Guys!
Thanks for all the feedback on this, I really appreciate the
suggestions. I think at the moment perhaps I'm struggling because the
way I build a 'view'. At the moment I've been doing it by stacking
multiple includes on account that I break of my visual code into it
display modules. So for example, I'll files like this:
invoice.details.cfm - A table that outputs an invoices object.
invoice.list.cfm - An table which outputs an array of invoices.
member.details.cfm - An table which outputs a member object.
Now, I can make two views up in my MG xml by simply appending the
includes together in an order that makes sense to me.
<event-handler name="page.view.member">
<broadcasts>
<message name="getMemberRecord" />
<message name="getMemberInvoices" />
</broadcasts>
<results>
<result do="view.template" />
</results>
<views>
<include name="body" template="member.details.cfm" />
<include name="body" template="invoice.list.cfm" append="true"
/>
</views>
</event-handler>
<event-handler name="page.view.invoice">
<broadcasts>
<message name="getInvoiceRecord" />
<message name="getMemberOtherInvoices" />
</broadcasts>
<results>
<result do="view.template" />
</results>
<views>
<include name="body" template="invoice.details.cfm" />
<include name="body" template="invoice.list.cfm" append="true"
/>
</views>
</event-handler>
<event-handler access="private" name="template.main">
<views>
<include name="main" template="templates/email_main.cfm" />
</views>
</event-handler>
See there how I can reuse my invoice.list.cfm in different locations?
However, if I'm understanding what you guys are suggesting my current
approach is flawed? and what I should perhaps be doing is only really
having one include for each of these events, and using a custom tag to
format the array of invoices into a nice table?
@Chris, I like the approach of having the framework render the views
for me to save me making HTTP requests, however, how do I have it
render a view including the template which is defined in the result?
The email_mail.cfm contains all my headers and CSS styles for an
email, so I need it to render everything.
Thanks guys, learning a great deal from all this.
Rob
On 5 Aug, 10:24, denstar <[email protected]> wrote:
> On Wed, Aug 5, 2009 at 3:11 AM, Chris Blackwell<[email protected]> wrote:
> > Hi Rob,
> > I don't know whether you found this but there was a similar discussion a
> > while back
> >http://groups.google.com/group/model-glue/browse_thread/thread/22ca37...
> > FWIW I favour the same approach as Dennis. The simplicity of keeping all my
> > templates as "views", rather than a mixture of views, custom tags and
> > home-grown templating language, is worth the trade-off of using MG in a
> > slightly unorthodox way to render those templates when needed.
> > Chris
>
> That sounds like a decent solution to mee too (especially since we
> don't do much fancy stuff in views, tho linkTo() and whatnot are
> getting us there), but I gotta say, that also sounds like mixing
> things that shouldn't be *cough*in a perfect world*cough*.
>
> For my money, "renderers" are where "it's" at. You're not
> copy-and-pasting various views from project to project, you can do
> inheritance type deals (theoretically reducing repetition, but it
> might depend on if you work on many projects or few projects, etc.),
> and you can use them in "views" (not just MG views).
>
> I mean, this is probably from futsing with eclipse, but it seems like
> the UI is a model itself, as confusing as that may be with terms like
> MVC (they're all models! ahhhhh!).
>
> Eh. I'll holler when I've got The Perfect Code to share, if ya dig,
> but that's sorta my line of thinking.
>
> --
> No noble or right style was ever yet founded but out of a sincere heart.
> --Ruskin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---