Changes between Initial Version and Version 1 of HowTos/HowToUseGenericDatabaseMessages/UsingmodelglueGenericList

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

--

Legend:

Unmodified
Added
Removed
Modified
  • HowTos/HowToUseGenericDatabaseMessages/UsingmodelglueGenericList

    v1 v1  
     1= Using modelglue.!GenericList = 
     2 
     3When this message is broadcast, the !DataController will attempt to list records from a given table. 
     4 
     5This message is configured by using the following <argument> tags: 
     6 
     7  1. Object (Required) - The name of the table to list. 
     8  1. !QueryName (Optional) - The name of the viewstate value to set the resultant query into. Defaults to Object & "Query". 
     9  1. Criteria (Optional) - A list of viewstate values to use as filters. Any value listed whose name matches a column in the target table will be used as a filter in the query's WHERE clause. 
     10  1. !OrderBy (Optional) - A single column name by which to order the query. 
     11  1. Ascending (Optional) - If set to true, order will be ascending. If set to false, order will be descending. 
     12 
     13== Examples == 
     14 
     15=== A Basic Generic List === 
     16 
     17To perform a basic list on a Contact table, the following <message> tag could be added to an <event-handler>: 
     18 
     19{{{ 
     20<message name="modelglue.GenericList"> 
     21 
     22<argument name="object" value="Contact" /> 
     23 
     24</message> 
     25}}} 
     26 
     27A View could then <cfdump> the query by performing the following code: 
     28 
     29{{{ 
     30<cfdump var="#viewstate.getValue("ContactQuery") /> 
     31}}} 
     32 
     33=== Customizing the Viewstate value name === 
     34 
     35To perform a basic list on a Contact table and set it into a specific value in the Viewstate, the following <message> tag could be added to an <event-handler>: 
     36 
     37{{{ 
     38<message name="modelglue.GenericList"> 
     39 
     40<argument name="object" value="Contact" /> 
     41 
     42<argument name="queryName" value="aListOfContacts" /> 
     43 
     44</message> 
     45}}} 
     46 
     47A View could then <cfdump> the query by performing the following code: 
     48 
     49{{{ 
     50<cfdump var="#viewstate.getValue("aListOfContacts") /> 
     51}}} 
     52 
     53=== Applying a Filter === 
     54 
     55To perform a basic list on a Contact table that would filter on the viewstate's current Firstname value, the following <message> tag could be added to an <event-handler>: 
     56 
     57{{{ 
     58<message name="modelglue.GenericList"> 
     59 
     60<argument name="object" value="Contact" /> 
     61 
     62<argument name="criteria" value="Firstname" /> 
     63 
     64</message> 
     65}}} 
     66 
     67Assuming an event-handler name of "contact.list", visiting the event handler with the following URL would result in only contacts with a Firstname of "Fred" being selected: 
     68 
     69index.cfm?event=contact.list&firstname=Fred 
     70 
     71=== Ordering === 
     72 
     73To perform a basic list on a Contact table ordered by Lastname (ascending), the following <message> tag could be added to an <event-handler>: 
     74 
     75{{{ 
     76<message name="modelglue.GenericList"> 
     77 
     78<argument name="object" value="Contact" /> 
     79 
     80<argument name="orderBy" value="Lastname" /> 
     81 
     82</message> 
     83}}} 
     84 
     85To reverse the order, the following argument tag could be added: 
     86 
     87{{{ 
     88<argument name="ascending" value="false" /> 
     89}}} 
     90 
     91A View could then <cfdump> the query by performing the following code: 
     92 
     93{{{ 
     94<cfdump var="#viewstate.getValue("ContactQuery") />