Take the 2-minute tour ×

Is it possible in ColdFusion that a non-persistent property could have a dynamic value?

An example would be


   property name="myID" length="100"    type="string"   fieldtype="id" generator="guid";

   property name="hasImageFlag"  persistent=false  default="{isNull(getItem().getIcon())};

   property name="Icon"  fieldtype="many-to-one" fkcolumn="imageID" cfc="image" lazy="true";

So in this example hasImageFlag could just be isNull(getItem().getIcon()) which would return true or false.

share|improve this question
OT: ColdFusion is one word. –  Jason Dean Sep 20 '11 at 17:19
OT: Spelling fixed. –  Leigh Sep 20 '11 at 18:57

3 Answers 3

up vote 2 down vote accepted

No, you cannot do that in cfproperty. For two reasons.

  1. It simply does not allow a dynamic default. So you can't even do default="#arrayNew(1)#"

  2. In your case, the getItem() method of this class will not exist yet while this code is running.

When I have needed dynamic defaults, I have done it in the init() constructor method so that it happens immediately after the object is created.

share|improve this answer
Am I right is saying the init() only runs on new enitity entity? –  Jon Weber Sep 20 '11 at 18:24

Actually, it seems like you're trying to re-invent Hibernate formulas, which are accessible through CF's ORM system as well.

share|improve this answer
I am serializing the ORM entity. I cannot get mapped properties so I want a flag to let my application know it needs to make another call to pull it. –  Jon Weber Sep 20 '11 at 18:28

What about using Hibernate event listeners? Ben Nadel has a decent primer here.

You might be able to do what you want using preLoad or postLoad...

share|improve this answer

Your Answer


