Changes between Initial Version and Version 1 of HowTos/HowToUseScaffolds/BroadcastsResultsandViewsinScaffolds

Show
Ignore:
Timestamp:
04/15/09 19:43:29 (17 years ago)
Author:
trac (IP: 127.0.0.1)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowTos/HowToUseScaffolds/BroadcastsResultsandViewsinScaffolds

    v1 v1  
     1= Using Broadcasts, Results and Views in Scaffolds = 
     2 
     3As we've seen in "How To Add A Scaffold," a single scaffold tag simply serves to define multiple event handlers. In order to keep the Model-Glue XML format easy to learn, the scaffold tag supports the same child tags (broadcasts, views, and results) as an event handler tag. 
     4 
     5Any broadcasts, views, or results tags added beneath a scaffold tag are applied to all event handlers a given scaffold creates. (To learn more about creating broadcasts, views, and results see the Quickstart guide). 
     6 
     7This allows us to extend the functionality of scaffolds in powerful ways. 
     8 
     9For example, to apply the sitewide template from the Model-Glue Application Template to all of the event handlers created by a given scaffold, we can simply add a result tag: 
     10 
     11{{{ 
     12<scaffold object="Contact"> 
     13 
     14<results> 
     15 
     16<result do="view.template" /> 
     17 
     18</results> 
     19 
     20</scaffold> 
     21}}} 
     22 
     23By splitting the types of scaffolds created amongst multiple scaffold tags for the same object, we can even apply message broadcasts to specific scaffold-generated event handlers. 
     24 
     25In a given application where anyone can view contacts but only administrators can update contacts, we could use the following XML in !ModelGlue.xml to protect the edit, commit, and delete event handlers from unauthorized access (assuming a message listener for "!UserMustBeAdministrator" performs security functionality and adds a result named "!SecurityViolation" in the event of bad access): 
     26 
     27{{{ 
     28<scaffold object="contact" type="list,view" /> 
     29 
     30<scaffold object="contact" type="edit,commit,delete"> 
     31 
     32<broadcasts> 
     33 
     34<message name="UserMustBeAdministrator" /> 
     35 
     36</broadcasts> 
     37 
     38<results> 
     39 
     40<result name="SecurityViolation" do="SecurityViolation" redirect="true" /> 
     41 
     42</results> 
     43 
     44</scaffold>