Changes between Initial Version and Version 1 of ReferenceMaterials/ViewApi

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

--

Legend:

Unmodified
Added
Removed
Modified
  • ReferenceMaterials/ViewApi

    v1 v1  
     1[[PageOutline]] 
     2 
     3= View API = 
     4 
     5Inside of a .CFM template used as a view, two CFC instances are available in the unnamed or "variables" scope: viewstate and viewcollection. 
     6 
     7Viewstate is used to access values from the viewstate. 
     8 
     9Viewcollection is used to access the rendered HTML of prior views. 
     10 
     11== !ViewCollection == 
     12 
     13In a .CFM template used as a View in a Model-Glue Application, the "viewcollection" variable gives access to the rendered results of prior views. 
     14 
     15This can be used to "stack" views. The following example shows a simple event handler in which one view, dspBody.cfm, is used inside of another (dspTemplate.cfm): 
     16 
     17{{{ 
     18<!-- In ModelGlue.xml --> 
     19 
     20<event-handler name="viewstacking"> 
     21 
     22<views> 
     23 
     24<include name="body" template="dspBody.cfm" /> 
     25 
     26<include name="main" template="dspTemplate.cfm" /> 
     27 
     28</views> 
     29 
     30</event-handler> 
     31 
     32<!--- dspBody.cfm ---> 
     33 
     34<p>Hi, I'm dspBody.cfm!</p> 
     35 
     36<!--- dspTemplate.cfm ---> 
     37 
     38<h1>dspTemplate.cfm</h1> 
     39 
     40<cfoutput>#viewcollection.getView("body")#</cfoutput> 
     41}}} 
     42 
     43== !ViewCollection.Exists(name:string) == 
     44 
     45==== Description: ==== 
     46 
     47Does a view of the given name exist in the viewcollection? 
     48 
     49==== Returns: ==== 
     50 
     51Boolean 
     52 
     53==== Arguments: ==== 
     54 
     55Name (required) - The name of the view to check 
     56 
     57== !ViewCollection.!GetView(name:string) == 
     58 
     59==== Description: ==== 
     60 
     61Returns the rendered results of a prior rendered view whose NAME attribute is the name argument passed. ''If the view does not exist, returns an empty string.'' 
     62 
     63==== Returns: ==== 
     64 
     65String 
     66 
     67==== Arguments: ==== 
     68 
     69Name (required) - The name of the view's content to retrieve 
     70 
     71== Viewstate == 
     72 
     73In a .CFM template used as a View in a Model-Glue Application, the "viewstate" variable gives access to form and url data, along with any values added in a controller function through the Event.!SetValue() method of the Event API. 
     74 
     75== Viewstate.Exists(name:string) == 
     76 
     77==== Description: ==== 
     78 
     79Does a value of the given name exist in the viewstate? 
     80 
     81==== Returns: ==== 
     82 
     83Boolean 
     84 
     85==== Arguments: ==== 
     86 
     87Name (required) - The name of the value to check 
     88 
     89== Viewstate.!GetAll() == 
     90 
     91==== Description: ==== 
     92 
     93Returns the structure that contains all viewstate members ''by reference''. 
     94 
     95==== Returns: ==== 
     96 
     97Struct 
     98 
     99==== Arguments: ==== 
     100 
     101None 
     102 
     103== Viewstate.!GetValue(name:string [, default:any]) == 
     104 
     105==== Description: ==== 
     106 
     107Returns a value from the viewstate, such as a form or url variable. 
     108 
     109==== Returns: ==== 
     110 
     111Any 
     112 
     113==== Arguments: ==== 
     114 
     115Name (required) - The name of the value to retrieve 
     116 
     117Default (optional) - If the value does not exist, a default value to set into the viewstate and then return