Tiered Events with Model-Glue

January 29, 2006

http://www.web-relevant.com/mg_tutorial


Model-Glue FAQ

January 29, 2006

General:

Which view in the view stack is displayed to the user?
Only the last view rendered is the one that is shown to the user.

Where are the HTML form and URL variables stored?
All HTML form and URL variables are stored in the ModelGlue.Core.Event object.

What is the order of firing events?
explicit results (those with a name attribute) will fire before implicit results (those without a name attribute).

Controller:

How to send data to a view?
To send data (including complex data types) to a view, use arguments.event.setValue("name", value)

How to access configuration settings in ModelGlue.xml?
To access the configuration settings in ModelGlue.xml (what’s between and ), use GetModelGlue().getConfigSetting("settingName")

How to invoke a mapped event?
To map a result to an event and invoke the event use arguments.event.addResult("eventName")

How to get a reference to a config bean?
Use

then use appConfig.getSettingName() to fetch the setting value.

How to access message arguments?
Use arguments.event.getArgument("name")

ModelGlue.xml:

How to send data to a view?
To send data to a view use the tag inside the tag like this:

You can specify whether or not to overwrite the value if it exists by adding the attribute overwrite=”true” or overwrite=”false” to the tag.

How to append to an existing view?
If we give an include tag a non-unique name, but add ‘append=”true”‘ to its attributes, it’ll add to the existing view’s content.

If ‘append=”true”‘ is not present, it’ll overwrite the existing view.

Can I have more than one controller declaration in ModelGlue.xml?
Yes, you can have multiple controller declarations, but each has to have a unique controller name.

Can multiple controllers listen to the same message?
Yes, multiple controllers can listen to the same message; In fact, they can listen more than once if they like. This is valid:

Should I declare a message-listener for every function in my controller?
No. Declare message listeners only for those functions that need to respond to messages.

Should the name of a message be the same as the name of the corresponding function in the controller?
No, they can be different. Both of the following are legitimate:


Are there any special messages built in into the framework?
In ModelGlue.xml, you can map the following special messages to functions in your controller:

onRequestStart: Put here any code that you need to execute at the start of each request.
onRequestEnd: Put here any code that you need to execute at the end of each request.
onQueueComplete: Put here any code that you need to execute after all views have been added to the queue and before they are rendered.

In case of multiple controller declarations, is the execution order of the OnRequestStart message listeners guaranteed ?
No, there is no guarantee of execution order.

Can I add arguments to my messages?
Yes, you can add an argument to a message like this:


You can then read the argument in the corresponding function in your controller like this: arguments.event.getArgument("name")

Views:

How to send data to the view or views that are rendered after the current one in the stack?
UseviewState.setValue("name","value")

How to read data sent from a controller, ModelGlue.xml or a previous view in the stack?
Use viewState.getValue("name", "default value")

How to check the existence of a view in the view stack?
Use viewCollection.Exists("viewName")

How to display the content of a previously defined view?
Use viewCollection.getView("viewName")

via:http://awads.net/wp/2005/06/24/model-glue-faq/


ColdFusion Cookbook

January 15, 2006

Raymond Camden创建的站点,目的就是帮助CFer快速解决问题,在这里你可以提交在开发CF中遇到的问题,由专人整理回复后分类列出来,相当于一个FAQ。并且此站点是用Model-Glue开发的。