What is "event-type" in model glue?

49 views
Skip to first unread message

saurav pandit

unread,
Mar 17, 2013, 3:48:34 PM3/17/13
to model...@googlegroups.com
Hi All,

"Model-Glue 3 introduces the concept of an Event Type. Much like Types in Object Oriented Programming, an Event Type contains specific behavior and is addressable by a specific name. Event Types in Model-Glue can contain behavior that is executed BEFORE, AFTER or BEFORE and AFTER an Event is executed."

So I started playing around it like following.
I have added "event-type" in my "modelglue.xml" add added one result tag under before. 
At this point I expect that model-glue will first execute the event "SomethingThatShouldRunBefore" which is inside "result" tag and then my event which is "default" and at last it will render the views inside "after" but what is happening model glue is only executing "SomethingThatShouldRunBefore".
My question is why rest of my event is not getting executed? 
Am I misunderstanding the meaning of the tags?
Can anybody tell me what I need to do to execute rest of my event?
  
<event-types>
<event-type name="templatedPage">
<before>
<results>
<result do="SomethingThatShouldRunBefore"/>
</results>
</before>
<after>
<views> 
<include name="navigation" template="layout/Layout.Navigation.cfm">
<value name="xe_ShipmentList" value="Shipment.List" />
</include>
<include name="message" template="layout/Layout.MessageBox.cfm" />
<include name="footer" template="layout/Layout.Footer.cfm" />
<include name="main" template="layout/Master.Layout.cfm" />
</views>
</after>      
</event-type>
</event-types>

<event-handlers defaultType="templatedPage">
<!-- A homepage for your application. -->
<event-handler name="default">
<views>
<include name="primary" template="primary.cfm" />
</views>
</event-handler>
<!-- An error event to show when an error occurs, much like <cferror>. -->
<event-handler name="page.error">
<views>
<include name="primary" template="layout/Master.Exception.cfm" />
</views>
</event-handler>
<!-- A "404" event to show when the requested event isn't defined. -->
<event-handler name="page.missing">
<broadcasts />
<views>
<include name="primary" template="layout/Master.MissingEvent.cfm" />
</views>
</event-handler>
</event-handlers>

<event-handlers>
<event-handler name="SomethingThatShouldRunBefore">
<views>
<include name="primary" template="secondary.cfm" />
</views>
</event-handler>
</event-handlers>

A Second try:-
In my second try I just change the content of "before" tag like following
<before>
<!--<results>
<result do="SomethingThatShouldRunBefore"/>
</results>-->
       <views>
               <include name="primary" template="secondary.cfm" />
</views>
</before>

Now It seems that my event is getting executed but problem is that the view inside "before" is not getting rendered.
Can anyone help me to render the view inside "before"(secondary.cfm)?

Thanks
Saurav

Dan Wilson

unread,
Mar 17, 2013, 5:09:21 PM3/17/13
to model...@googlegroups.com

That looks pretty good on first glance. You have the right idea.

I'm on my phone, so I'm sure I'm missing something. I'll look more in detail when I get home tomorrow.

--
--
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 model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en
---
You received this message because you are subscribed to the Google Groups "model-glue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to model-glue+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dan Wilson

unread,
Mar 18, 2013, 9:13:07 AM3/18/13
to model...@googlegroups.com
I believe the best thing you can do right now is to turn on ModelGlue debugging and figure out when the various items are being run.

It's possible there is a redirect happening, which would reset the event queue immediately.
It's also possible you have two views named the same and aren't using the append="true" option.

With the ModelGlue debugging turned on, you would be able to trace what ran, and when. That will help us diagnose a little bit easier.

To turn on debugging, go into your application specific coldspring.xml and find the bean definition for modelglue.modelGlueConfiguration

Set <property name="debug"><value>true</value></property> and reload your application. The debugging information will be at the bottom of your rendered page.

Report back what you find. If you aren't able to resolve this on your own, post the contents of the debug information along with your Model Glue events and event-types in question.

DW
Sunday, March 17, 2013 3:48 PM

saurav pandit

unread,
Mar 18, 2013, 3:57:24 PM3/18/13
to model...@googlegroups.com
ModelGlue.xml
<?xml version="1.0" encoding="UTF-8"?>
<modelglue>
<controllers>
<controller id="GlobalController" type="PlantOMatic.controller.GlobalController">
<message-listener message="onRequestStart" function="doSetUp" />
<message-listener message="require"  function="require" />
</controller>
</controllers>
<event-types>
<event-type name="templatedPage">
<before>
<results>
<result do="SomethingThatShouldRunBefore"/>
</results>
<!--<views>
<include name="SomethingThatShouldRunBefore" template="secondary.cfm" append="true"/>
</views>-->
<include name="SomethingThatShouldRunBeforetemplate" template="secondary.cfm" append="true"/>
</views>
</event-handler>
</event-handlers>
</modelglue>
<!-- 
Sample Event Handler:
<event-handler name="eventname">
<broadcasts>
<message name="message" />
</broadcasts>
<results>
<result name="resultName" do="otherEvent" />
</results>
<views>
<include name="body" template="content.cfm" />
</views>
</event-handler> 
-->

Debugging Information
I have not provided whole debugging information but this is from where we are getting event "default".
Here I can see it is queuing "default" event first and also executing it and after that it is queuing the event "SomethingThatShouldRunBefore" but not executing it.
I am not sure what I am missing.
one more thing can we render multiple view without using "viewcollection"?

let say we have tag like following
<views> 
<include name="v1" template="v1.cfm"/>
<include name="v2" template="v2.cfm" />
</views>
In this case I always get the content of "v2.cfm" not a combination of "v1.cfm" and "v2.cfm"
Can anyone say how could I achieve the above combination without using "viewCollection" 

461msEvent QueueQueueing event handler: default
  
462msEvent HandlerExecute "default"
 <event-handler name="default"> 
462msResultImplicit result queing event "SomethingThatShouldRunBefore"
 <result do="SomethingThatShouldRunBefore" /> 
462msEvent QueueQueueing event handler: SomethingThatShouldRunBefore
  
462msView QueueView queued: primary.cfm
  
463msView QueueView queued: layout/Layout.Navigation.cfm
  
463msView QueueView queued: layout/Layout.MessageBox.cfm
  
463msView QueueView queued: layout/Layout.Footer.cfm
  
463msView QueueView queued: layout/Master.Layout.cfm
  
463msEvent HandlerExecute "SomethingThatShouldRunBefore"
 <event-handler name="SomethingThatShouldRunBefore"> 
463msView QueueView queued: secondary.cfm
  
463msEvent HandlerExecute "modelglue.onQueueComplete"
 <event-handler name="modelglue.onQueueComplete"> 
463msMessage BroadcastBroadcasting "onQueueComplete"
 <message name="onQueueComplete"> 
464msViewsRendering view "primary" (primary.cfm)
 <include name="primary" template="primary.cfm" /> 
466msViewsRendering view "navigation" (layout/Layout.Navigation.cfm)
 <include name="navigation" template="layout/Layout.Navigation.cfm" /> 
468msViewsRendering view "message" (layout/Layout.MessageBox.cfm)
 <include name="message" template="layout/Layout.MessageBox.cfm" /> 
470msViewsRendering view "footer" (layout/Layout.Footer.cfm)
 <include name="footer" template="layout/Layout.Footer.cfm" /> 
473msViewsRendering view "main" (layout/Master.Layout.cfm)
 <include name="main" template="layout/Master.Layout.cfm" /> 
475msViewsRendering view "SomethingThatShouldRunBeforetemplate" (secondary.cfm)
 <include name="SomethingThatShouldRunBeforetemplate" template="secondary.cfm" /> 
477msEvent QueueQueueing event handler: modelglue.onRequestEnd
  
478msEvent HandlerExecute "modelglue.onRequestEnd"
 <event-handler name="modelglue.onRequestEnd"> 
478msMessage BroadcastBroadcasting "onRequestEnd"
 <message name="onRequestEnd"> 
478msInvocationRequest phase complete.

Please inform me if anyone need any further information.

Thanks 
Saurav

Dan Wilson

unread,
Mar 18, 2013, 4:09:02 PM3/18/13
to model...@googlegroups.com
It looks like everything is running just fine. I did notice you used a result, which is going to queue up in the results queue, which is after your views are rendered... If you want Secondary to be available first, you may want to replace this:

<results>
<result do="SomethingThatShouldRunBefore"/>
</results>
 
With this:

<views>
<include name="SomethingThatShouldRunBeforetemplate" template="secondary.cfm" append="true"/>
</views>
 
Also:


let say we have tag like following
<views> 
<include name="v1" template="v1.cfm"/>
<include name="v2" template="v2.cfm" />
</views>
In this case I always get the content of "v2.cfm" not a combination of "v1.cfm" and "v2.cfm"
Can anyone say how could I achieve the above combination without using "viewCollection" 
 

I think you pretty much have to use the view collection. That's where everything is. So if you want the content, that's the place to get it. The View content will be rendered and made available for you to use wherever in the page you like. ModelGlue can't really make the guess for you.

However, if what you are trying to do is append the views together (like a concatenation), then you would just give them the same name and use the append attribute like this:

<views> 
<include name="v1" template="v1.cfm" append="true" />
<include name="v1" template="v2.cfm" append="true"  />
</views>




DW

Monday, March 18, 2013 3:57 PM
--
--
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 model...@googlegroups.com
To unsubscribe from this group, send email to
model-glue+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en
---
You received this message because you are subscribed to the Google Groups "model-glue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to model-glue+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Monday, March 18, 2013 9:13 AM
I believe the best thing you can do right now is to turn on ModelGlue debugging and figure out when the various items are being run.

It's possible there is a redirect happening, which would reset the event queue immediately.
It's also possible you have two views named the same and aren't using the append="true" option.

With the ModelGlue debugging turned on, you would be able to trace what ran, and when. That will help us diagnose a little bit easier.

To turn on debugging, go into your application specific coldspring.xml and find the bean definition for modelglue.modelGlueConfiguration

Set <property name="debug"><value>true</value></property> and reload your application. The debugging information will be at the bottom of your rendered page.

Report back what you find. If you aren't able to resolve this on your own, post the contents of the debug information along with your Model Glue events and event-types in question.

DW
Sunday, March 17, 2013 3:48 PM
Hi All,

"Model-Glue 3 introduces the concept of an Event Type. Much like Types in Object Oriented Programming, an Event Type contains specific behavior and is addressable by a specific name. Event Types in Model-Glue can contain behavior that is executed BEFORE, AFTER or BEFORE and AFTER an Event is executed."

So I started playing around it like following.
I have added "event-type" in my "modelglue.xml" add added one result tag under before. 
At this point I expect that model-glue will first execute the event "SomethingThatShouldRunBefore" which is inside "result" tag and then my event which is "default" and at last it will render the views inside "after" but what is happening model glue is only executing "SomethingThatShouldRunBefore".
My question is why rest of my event is not getting executed? 
Am I misunderstanding the meaning of the tags?
Can anybody tell me what I need to do to execute rest of my event?
  
<event-types>
<event-type name="templatedPage">
<before>
<results>
<result do="SomethingThatShouldRunBefore"/>
</results>
<include name="primary" template="secondary.cfm" />
</views>
</event-handler>
</event-handlers>

A Second try:-
In my second try I just change the content of "before" tag like following
<before>
<!--<results>
<result do="SomethingThatShouldRunBefore"/>
</results>-->
       <views>

saurav pandit

unread,
Mar 18, 2013, 4:41:00 PM3/18/13
to model...@googlegroups.com
Hi Dan,

Thanks a lot for your help.

I have tried the solution provided by you and it is working.
I still have question regarding "before" tag. I thought that whatever I will write inside "before" that get completed first.
So in my case it should execute the event "SomethingThatShouldRunBefore" and queu the view "SomethingThatShouldRunBeforetemplate" then it should do remaining task. It seems that I have wrong idea.
It will helpful if you help me to understand the behavior of "before" tag and thanks again for your reply. 
 
Thanks
Saurav

Dan Wilson

unread,
Mar 18, 2013, 4:42:57 PM3/18/13
to model...@googlegroups.com
Glad it is working.

You are correct in thinking the <before> things run before. However, you must apply this in terms of the Model Glue request lifecycle.

The result you have in your <before> tag, runs before any other results. Results run after the initial event has completed. This explains the behavior you see.

DW

Monday, March 18, 2013 4:41 PM
Monday, March 18, 2013 4:09 PM
Reply all
Reply to author
Forward
0 new messages