Improving page flow
The page was refreshed and showed us an update. But it might not be obvious that an update was made. There is also an issue that it does not appear as if the data was updated because we pulled the data object details before the update was made. Also when we saved our edit page data, it would be nice if we were sent back to the list page. Let us take a look at the redirect tag in ColdFusion, <cflocation>
. After an insert or update, the browser will be returned back to the list page. We will also pass a message to the page so that the user will see the updates. First, we will create a message in each of our insert and action code segments. Then, we will push the page back to the list page by passing the message with it:
<cfif structKeyExists(attributes,"submit")> <cfif attributes.id EQ 0> <cfquery datasource="cfb" name="qryInsert"> INSERT INTO product( name , description , price ) VALUES( <cfqueryparam value="#attributes.name#">...