Interesting point Chuck, thanks for bringing it up. This is actually a
feature, though it may indicate a bug in the documentation.

Here's why:

MG has an order of operations. In that order of operations, we always to the
following:

Broadcast Messages
Include Views
Process Results

When you add the event type containing the template.header event into your
before event, what you are actually doing is telling MG to add in the result
before the rest of the results.

When the event executes, it queues the stuff in your event types. codified
with <before>, then it queues the event stuff, then it queues the stuff in
your event types codified with <after>. Once all the queueing is completed,
then the queue is executed.

>From the logging, MG is working as intended, thus this is a feature. The
result for your template.header is run before any other result. (read the MG
debugging output to see this queueing in action) I agree though, the effect
isn't what you intended though.

Rather than using a result to deal with the header, why not stick the
broadcasts and the views directly in the event type?

 <event-type name="beforeMainTemplate">
     <before>
<broadcasts>
               <message name="templates.header" />
       </broadcasts>
       <results />
       <views>
               <include name="header" template="templates/header.cfm" />
       </views>
     </before>
   </event-type>

That would do exactly as you want,


I'm going to make a note to blog this. If you had trouble with the way this
works, I'm sure others will as well.


DW




On Wed, Nov 11, 2009 at 5:26 PM, Chuck <[email protected]> wrote:

>
> I've been trying to get a grasp on event flow, and it seems to me that
> event-type's <before> tag, the things defined in there should execute
> BEFORE everything else in the event that includes that event type in
> its Type property.
>
> Tell me is this a feature or bug ... some code
>
>  <event-type name="beforeMainTemplate">
>      <before>
>        <results>
>          <result do="templates.header" />
>        </results>
>      </before>
>    </event-type>
>
> The Event...
>
> <event-handler name="templates.header">
>        <broadcasts>
>                <message name="templates.header" />
>        </broadcasts>
>        <results />
>        <views>
>                <include name="header" template="templates/header.cfm" />
>        </views>
> </event-handler>
>
> The event that includes the Type
> <event-handler access="private" name="template.main"
> type="beforeMainTemplate">
>        <broadcasts>
>                <message name="templates.footer" />
>        </broadcasts>
>        <views>
>                <include name="footer" template="templates/footer.cfm" />
>                <include name="main" template="templates/main.cfm" />
>        </views>
> </event-handler>
>
> I've tried this with the footer event, but get the same results, see
> below
>
> The debug output...
> 765ms   Views   Rendering view "body" (pages/index.cfm)
>        <include name="body" template="pages/index.cfm" />
> 765ms   Views   Rendering view "footer" (templates/footer.cfm)
>        <include name="footer" template="templates/footer.cfm" />
> 781ms   Views   Rendering view "main" (templates/main.cfm)
>        <include name="main" template="templates/main.cfm" />
> 781ms   Views   Rendering view "header" (templates/header.cfm)
>        <include name="header" template="templates/header.cfm" />
>
> Why is it that the view is rendered last when it is in a <before>
> tag?  Again is this a feature or bug?
>
>
> >
>


-- 
“Come to the edge, he said. They said: We are afraid. Come to the edge, he
said. They came. He pushed them and they flew.”

Guillaume Apollinaire quotes

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to