-
Notifications
You must be signed in to change notification settings - Fork 12
UsingmodelglueGenericList
When this message is broadcast, the DataController will attempt to list records from a given table.
This message is configured by using the following tags:
- Object (Required) - The name of the table to list.
- QueryName (Optional) - The name of the viewstate value to set the resultant query into. Defaults to Object & "Query".
- 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.
- OrderBy (Optional) - A single column name by which to order the query.
- Ascending (Optional) - If set to true, order will be ascending. If set to false, order will be descending.
To perform a basic list on a Contact table, the following tag could be added to an :
<message name="modelglue.GenericList">
<argument name="object" value="Contact" />
</message>
A View could then the query by performing the following code:
<cfdump var="#viewstate.getValue("ContactQuery")#" />
To perform a basic list on a Contact table and set it into a specific value in the Viewstate, the following tag could be added to an :
<message name="modelglue.GenericList">
<argument name="object" value="Contact" />
<argument name="queryName" value="aListOfContacts" />
</message>
A View could then the query by performing the following code:
<cfdump var="#viewstate.getValue("aListOfContacts")#" />
To perform a basic list on a Contact table that would filter on the viewstate's current Firstname value, the following tag could be added to an :
<message name="modelglue.GenericList">
<argument name="object" value="Contact" />
<argument name="criteria" value="Firstname" />
</message>
Assuming 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:
index.cfm?event=contact.list&firstname=Fred
To perform a basic list on a Contact table ordered by Lastname (ascending), the following tag could be added to an :
<message name="modelglue.GenericList">
<argument name="object" value="Contact" />
<argument name="orderBy" value="Lastname" />
</message>
To reverse the order, the following argument tag could be added:
<argument name="ascending" value="false" />
A View could then the query by performing the following code:
<cfdump var="#viewstate.getValue("ContactQuery")#" />