Luis Majano Forums Notification: Post to Best way to handle mulitple views

Title: RE: Best way to handle mulitple views
Thread: Best way to handle mulitple views
Forum: Need Help?
Conference: ColdBox
User: lmajano

Hi tonyg,

There are so many ways you can do this, but it all depends exactly
on what you are trying to accomplish. Using the renderer plugin, you can render
content and those views use the request collection. Now if a view needs an event
to be fired that per say is not part of the main event, then I usually have been
using the view as as 'viewlet' or module. This way the view itself is tied to
its data event. Sort of a page controller concept.

So all I need to do is
render the viewlet and the viewlet itself calls the event using the 'runEvent()'
method available to it.

I usually have created a viewlets directory under my

+ views
+---| viewlets
    >--- myviewlet.cfm

So whenever I want
to render a viewlet, I just say:


Once the viewlet get's rendered by the plugin, it will detect the run
event call. I prefer this method than actually calling the runevent from
another event. Since I do not want to couple it to that specific event. I want
to couple my event to my view. This is important to bring a decoupling to your
events. At the end of the day, the view is the end result of the event. Thus,
they are coupled.