It is not giving an error, but the data values are not staying when comment page is refreshed. It does show the values immediately after loading but not after refresh.
Something worth noting is the variables for ALL the blog section are not working without the get() in the variables. For example, instead of #blogpost.title#, it wants #blogpost.getTitle()#. The duplicate site does not do that, and when I had that issue then, I simply deleted the db tables, repopulated them, and then it worked. I just deleted the db blog tables and repopulated them and both the comment issue and get() issue still neeed resolved. Maybe the get() is related or should be addressed first?
Here is a <cfdump var="#blogpost#"> :
component workexperience.www.com.entity.blogPost | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PROPERTIES |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
METHODS |
Date Posted:01/01/2005
Here is the refreshed <cfdump var="#blogpost#"> Notice the empty strings in author, comment, and createdDateTime now.
component workexperience.www.com.entity.blogPost | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PROPERTIES |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
METHODS |
Here is the blogpost.cfm page with the comment form. The difference between this page and the same page that works in the duplicate site is the !CSRFVerifyToken(form.token). The duplicate site that is working has !isSimpleValue(form.token), instead. But the learncfinaweek site has the !CSRFVerifyToken....
<cfset blogPost = EntityLoad('BlogPost',url.id,true) />
<cfset blogCategories = EntityLoad('BlogCategory') />
<cfparam name="form.submitted" default="0" />
<cfparam name="form.token" default="" />
<cfif form.submitted>
<cfif isSimpleValue(form.author)>
<cfset form.author = canonicalize(form.author, true, true) />
</cfif>
<cfif isSimpleValue(form.comment)>
<cfset form.comment = canonicalize(form.comment, true, true) />
</cfif>
<cfif !isSimpleValue(form.author) || !isSimpleValue(form.comment) || !CSRFVerifyToken(form.token)>
<cfthrow message="Validation Error">
</cfif>
<cfset comment=entityNew('blogComment') />
<cfset comment.author=form.author />
<cfset comment.comment=form.comment />
<cfset comment.createdDateTime=now() />
<cfset blogPost.addComment(comment) />
<cfset entitySave(blogPost) />
</cfif>
<cfimport taglib="customTags/" prefix="layout" />
<layout:page section="blog">
<!-- Content Start -->
<!--Card -->
<div id="content">
<div class="card-pattern">
<!-- blog -->
<div id="blog">
<div class="clr">
<div class="top-bg1">
<div class="top-left">
<div><h1>Blog</h1></div>
</div>
</div>
<div class="clr">
<div class="pat-bottomleft"> </div>
<div class="pat-bottomright"> </div>
</div>
</div>
<div class="blog-top">
<div class="clr">
<cfoutput>
<div class="left">
<!-- Blog Title -->
<h2 class="big">
#blogPost.getTitle()#
</h2>
<cfdump var="#blogpost#">
<!-- Date Published -->
<h5>
<strong>Date Posted</strong>:#dateformat(blogPost.getDatePosted(),'mm/dd/yyyy')#
</h5>
<!-- Blog Body -->
#blogPost.getBody()#
<!-- Blog Export -->
<p>
<a href="exportToPDF.cfm?id=#blogPost.getid()#" target="_new"><img src="assets/images/export_pdf.png" border="0"/></a>
</p>
<!-- Blog Comments Section -->
<h3>
Comments (#arrayLen(blogPost.getComments())#)
</h3>
<div class="clr hline"> </div>
<div class="clr comments">
<ul>
<!-- Start Comment -->
<cfloop array="#blogPost.getComments()#" index="comment">
<li>
<p>
<strong>Posted On:</strong> #dateformat(comment.getCreatedDateTime(),'mm/dd/yyyy')# at #timeformat(comment.getCreatedDateTime(),'short')# By #encodeForHTML(comment.getauthor())#
</p>
<p>
#encodeForHTML(comment.getComment())#
</p>
<div class="clr hline"> </div>
</li>
<!-- End Comment -->
</cfloop>
</ul>
</div>
<h3>
Post Comment
</h3>
<div class="clr hline"> </div>
<div class="clr postComment">
<form action="blogpost.cfm?id=#blogPost.getId()#" method="post" id="form">
<div>
<label>Name <span class="font-11">(required)</span></label>
<input name="author" type="text" class="required" />
</div>
<div class="textarea">
<label>Comment <span class="font-11">(required)</span></label>
<textarea name="comment" rows="6" cols="60" class="required"></textarea>
</div>
<div>
<input id="submitBtn" value="Submit" name="submit" type="submit" class="submitBtn" />
</div>
<input type="hidden" name="submitted" value="1" />
<input type="hidden" name="token" value="#CSRFGenerateToken()#" />
</form>
</div>
</div>
</cfoutput>
<div class="right" >
<h2>Categories</h2>
<!-- Blog Specific Categories -->
<div id="categories" align="center">
<ul>
<cfoutput>
<cfloop array="#blogCategories#" index="blogCategory">
<li><a href="#blogCategory.getName()#">#blogCategory.getName()#</a></li>
</cfloop>
</cfoutput>
</ul>
</div>
</div>
</div>
</div>
<div class="clr"></div>
</div> <!--blog end -->
</layout:page>