I am sure that I am doing something wrong here but not quite sure what
it is! I have a post controller that auto wires transfer and a post
service for me. I am not sure what I am caching or where but every
time I call my show method the post object is cached. If I update the
database im still getting the old object (same data). Is it transfer
thats getting cached or is this controller getting cached?
Anyways, im sure I am doing something wrong so if someone can point
out whats wrong here that would be a big help!
Thanks
<cfcomponent name="post" extends="coldbox.system.eventhandler"
output="false" hint="Post Controller" autowire="true">
<cfproperty name="Transfer" type="ocm" scope="instance" />
<cfproperty name="PostService" type="ioc" scope="instance" />
<cffunction name="index" access="public" output="false"
returntype="void">
<cfset setNextRoute("post/list")>
</cffunction>
<cffunction name="list" access="public" output="true"
returntype="any">
<cfargument name="event" type="coldbox.system.beans.requestContext"
required="true">
<cfscript>
var orderby = event.getValue("orderby","posted");
var sortAsc = event.getValue("orderSort",false);
var posts = instance.transfer.list("post",orderby,sortAsc);
page = {pageTitle="List Posts",posts=posts};
event.collectionAppend(page,false);
</cfscript>
</cffunction>
<cffunction name="show" access="public" output="true"
returntype="any">
<cfargument name="event" type="coldbox.system.beans.requestContext"
required="true">
<cfscript>
var postId = event.getValue("id",0);
if(!postId){
event.setValue("message","User with an id of #postId# was not
found");
event.setValue("pageTitle", "List Posts");
setNextRoute("post/list","orderby");
} else {
// update the views count
instance.postService.updateViews(postId);
// post instance - do after update so we have correct view count
post = instance.transfer.get("post",postId);
// place our post into the event
event.setValue("post", post);
}
</cfscript>
</cffunction>
</cfcomponent>