Skip to main content
December 5, 2015
Answered

Element TITLE is undefined in BLOGPOST

  • December 5, 2015
  • 1 reply
  • 1092 views

I have several errors that I could use some help on.  Below is just one of them.  I mention that in case I need to bring them all up in order to troubleshoot this correctly.  Maybe it is worth noting that I am going through the learncfinaweek.com hands on (ORM) and have most of the code working except the categories that keep the boxes checked in editBlogPost.cfm and Categories are not saving correctly.  That said, here is the first error:

The cfdump showed that title is getting pulled in, so I would like to know why it won't pass the var. 

Element TITLE is undefined in BLOGPOST

  The error occurred in C:/ColdFusion11/cfusion/wwwroot/learncfinaweek/chapter1solution/admin/content/blog/listblogpost.cfm: line 34

listBlogPost.cfm:

<cfimport taglib="../../customTags" prefix="ct" />

<ct:securityCheck redirectPage="#cgi.script_name#"/>

<cfset adminPath = createObject('learncfinaweek.chapter1solution.admin.cfc.system').getBasePath(cgi.script_name) />

<!--- Pull Blog Posts --->

<cfset blogPosts = EntityLoad('BlogPost') />

<cfoutput>

  <ct:layout section="blog">

  <ct:navigation section="blog" active="post"/>

  <div class="span10">

  <h2>Blog</h2>

     <form class="navbar-form pull-right">

      <a class="btn btn-primary" href="<cfoutput>#adminPath#</cfoutput>/content/blog/editblogpost.cfm">

  <i class="icon-plus icon-white"></i>

  New Blog Post

  </a>

     </form>

  <table class="table table-hover">

  <thead>

  <tr>

  <th>Title</th>

  <th>Publish Date</th>

  <th>Actions</th>

  </tr>

  </thead>

  <tbody>

  <cfloop array="#blogPosts#" index="blogPost">

  <tr>

  <td>

  <!--- Title --->

  #blogPost.title#

  </td>

  <td>

  <!--- Date Posted --->

  #dateFormat(blogPost.datePosted,"mm/dd/yyyy")#

  </td>

  <td>

  <!--- Edit Post --->

  <a href="#adminPath#/content/blog/editblogpost.cfm?id=#blogPost.id#"><i class="icon-edit"></i></a>

  </td>

  </tr>

  </cfloop>

  </tbody>

     </table>

  </div>

  </ct:layout>

</cfoutput>

blogPost.cfc:

component persistent="true" {

  Property name="id" column="blogpostid" fieldtype="id" generator="increment";

  Property name="title" ormtype="text";

  Property name="summary" ormtype="text";

  Property name="body" ormtype="text";

  Property name="dateposted" ormtype="timestamp";

  Property name="createdDateTime" ormtype="timestamp";

  Property name="modifiedDateTime" ormtype="timestamp";

  Property name="deleted" ormtype="boolean";

  Property name="comments" singularname="comment" fieldtype="one-to-many" cfc="blogComment" fkcolumn="blogpostid" cascade="all";

  Property name="categories" fieldtype="one-to-many" cfc="blogPostCategory" fkcolumn="blogPostid";

  public string function getCategoryIDs() {

  var categoryList = '';

  if ( hasCategories() ) {

  for (var categoryPost in getCategories() ) {

  categoryList = listAppend( categoryList, categoryPost.blogCategory.id);

  }

  }

  return categoryList;

  }

  public string function getCategoryNames(){

  var categoryList = '';

  if(hasCategories()){

  for(var categoryPost in getCategories()){

  categoryList = listAppend(categoryList, categoryPost.blogCategory.name,', ');

  }

  }

  return categoryList;

  }

}

This topic has been closed for replies.
Correct answer BKBK

To get the value of the property X of an entity, use myEntity.getX() instead of myEntity.X. That is,

blogPost.getTitle() instead of blogPost.title

1 reply

BKBK
Community Expert
BKBKCommunity ExpertCorrect answer
Community Expert
December 6, 2015

To get the value of the property X of an entity, use myEntity.getX() instead of myEntity.X. That is,

blogPost.getTitle() instead of blogPost.title

December 7, 2015

Thank You.  That displayed the data Title for me.  Some of the categories are empty and some of them are named the same name.  Is that the reason why it is giving an error?  I guess I should get the category section fully working and try to delete them from there maybe?

BKBK
Community Expert
Community Expert
December 7, 2015

DavidSCarlisle55 wrote:

That displayed the data Title for me.

OK. So we have solved that one.

DavidSCarlisle55 wrote:

Some of the categories are empty and some of them are named the same name.  Is that the reason why it is giving an error?  I guess I should get the category section fully working and try to delete them from there maybe?

The original error was about the title. As you say, the title is now displayed. Is the current error about categories?