views:

121

answers:

1

Hiya:

I wonder if anybody has an idea on this...

I'm looking at securing a low level object in my model (a "member" object) so by default only certain information can be accessed from it.

Here's a possible approach (damn sexy if it would work!):

1) Add a property called "locked" - defaulting to "true" to the object itself.

It appears that the only option to do this, and not tie it to a db table column, is to use the formula attribute that takes a query. So to default locked to TRUE I've got:

<cfproperty name="locked" formula="select 1" />

2) Then, I overwrite the existing set-ers and get-ers to use this: e.g.

<cffunction name="getFullname" returnType="string"> 
 <cfscript>
  if (this.getLocked()) {
   return this.getScreenName();
  } else {
   return this.getFullname();
  }

 </cfscript>
</cffunction>

3) When i use it like this:

<p> #oMember.getFullName()# </p>

shows the ScreenName (great!)

but... When I do this:

<cfset oMember.setLocked(false)>
<p> #oMember.getFullName()# </p>

Just hangs!!! It appears that attempting to set a property that's been defined using "formula" is a no-no.

Any ideas? Any other way we can have properties attached to an ORM object that are gettable and settable without them being present in the db?

Ideas appreciated!

A: 

Any other way we can have properties attached to an ORM object that are gettable and settable without them being present in the db?

Yes,

<cfproperty name="locked" persistent=false>

http://help.adobe.com/en%5FUS/ColdFusion/9.0/Developing/WSB7BEC0B4-8096-498d-8F9B-77C88878AC6C.html

Henry
Thanks Henry. I still seem to get the same behaviour.... As soon as I try to setLocked(true) the code just hangs (seems to return an empty page...).
Henry: It seems that the implicit setter setLocked isn't defined by Hibernate.... But, when I create one it doesn't seem to work... i'm beginning to think this might be a CF ORM bug. What do you think?
Henry
Maybe you forgot to set variables.locked = #defaultLockState# in constructor or sudo-constructor?
Henry
Oh, and don't forget to restart your CF instance...
Henry