• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Comments not holding data values

Guest
Feb 09, 2016 Feb 09, 2016

Copy link to clipboard

Copied

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
id1
titletitle
summarysummary
bodybody
dateposted2005-01-01 00:00:00.0
createdDateTime2005-10-10 10:10:55.0
modifiedDateTime2005-10-10 10:10:55.0
deleted[empty string]
comments
array
1
component workexperience.www.com.entity.blogComment
PROPERTIES
id2
author[empty string]
comment[empty string]
createdDateTime[empty string]
deleted[empty string]
blog  [see cfc1 for blogPost details]
METHODS
2
component workexperience.www.com.entity.blogComment
AUTHORcomment Name Here
COMMENTcomment body here
CREATEDDATETIME{ts '2016-02-09 14:48:54'}
PROPERTIES
id[empty string]
author[empty string]
comment[empty string]
createdDateTime[empty string]
deleted[empty string]
blog[empty string]
METHODS
categories
array
1
component workexperience.www.com.entity.blogPostCategory
PROPERTIES
blogPost  [see cfc1 for blogPost details]
blogCategory
component workexperience.www.com.entity.blogCategory
PROPERTIES
id1
nameJesusName
posts
array
1[see cfc4 for blogPostCategory details]
METHODS
METHODS
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
id1
titletitle
summarysummary
bodybody
dateposted2005-01-01 00:00:00.0
createdDateTime2005-10-10 10:10:55.0
modifiedDateTime2005-10-10 10:10:55.0
deleted[empty string]
comments
array
1
component workexperience.www.com.entity.blogComment
PROPERTIES
id2
author[empty string]
comment[empty string]
createdDateTime[empty string]
deleted[empty string]
blog  [see cfc1 for blogPost details]
METHODS
2
component workexperience.www.com.entity.blogComment
PROPERTIES
id3
author[empty string]
comment[empty string]
createdDateTime[empty string]
deleted[empty string]
blog  [see cfc1 for blogPost details]
METHODS
categories
array
1
component workexperience.www.com.entity.blogPostCategory
PROPERTIES
blogPost  [see cfc1 for blogPost details]
blogCategory
component workexperience.www.com.entity.blogCategory
PROPERTIES
id1
nameJesusName
posts
array
1[see cfc4 for blogPostCategory details]
METHODS
METHODS
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>

TOPICS
Getting started

Views

816

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2016 Feb 14, 2016

Copy link to clipboard

Copied

  • When you refresh the page, no form is submitted.
  • Hence, form.submitted is 0.
  • This in turn implies that Coldfusion won't execute the lines

        <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) />

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 01, 2016 Mar 01, 2016

Copy link to clipboard

Copied

Is the <cfset entitySave(blogPost) /> not saving the values in the database then? Because, blogPost.getComments() should pull it up if it is saved.?

When !CSRFVerifyToken(form.token) is used, the dump brings the values up when first submitted but not when refreshed.  When !isSimpleValue(form.token) is used, the dump brings up nothing when first submitted and when refreshed.  Neither displays the data on the page, only the dump shows the above, even when the first submitted has values in the dump and should show on the page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 02, 2016 Mar 02, 2016

Copy link to clipboard

Copied

DavidSCarlisle55 wrote:

Is the <cfset entitySave(blogPost) /> not saving the values in the database then?

Not when you refresh the page.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 25, 2016 Jun 25, 2016

Copy link to clipboard

Copied

First, I ask that you pray that my computer is restored to me.  Do not let people steal my computer, technology, please.  Do not let people be against me benefiting myself and others with computers!  Pray for the restoration of me and my freedom to program.

Thank You,

David

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2016 Jun 27, 2016

Copy link to clipboard

Copied

LATEST

Have faith, and you should be all right in the end, David. Did you solve the entitySave() problem?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation