Aha I see. Yeah I did think cloning might be the answer. I can't really do
decorator.
The parent cloning idea might work a treat though - thanks.
I'll go this route in future then if it's the recommended approach.
-----Original Message-----
From: transfer-dev@googlegroups.com [mailto:transfer-dev@googlegroups.com]
On Behalf Of Mark Mandel
Sent: 05 May 2008 17:17
To: transfer-dev@googlegroups.com
Subject: [transfer-dev] Re: Caching of new objects that aren't persisted
Why not just set the parent if the validation passes?
Failing that, you should be able to clone the parent, and then save it that
way.
Mark
On Mon, May 5, 2008 at 9:17 AM, James Allen <slingsho...@googlemail.com>
wrote:
> Hi Mark,
> No I checked the DB and nothing is saved. Is this happening because I am
> attaching the object to it's parent. I.E this is a new answer being
created
> which has a setParentQuestion() method run to tie it to an already
persisted
> question. Therefore the answer appears immediately even if I don't save
it.
> Once I re-init transfer it goes. Here's the creation code:
> <cfargument name="ID" type="numeric" default="0" />
> <cfargument name="AnswerText" type="string"
required="false"
> />
> <cfargument name="AnswerOption" type="numeric"
> required="false" />
> <cfargument name="Rating" type="numeric" required="false"
/>
> <cfargument name="PosterIP" type="string" required="false"
> />
> <cfargument name="PostDate" type="date" required="false"
/>
> <cfargument name="userBean" type="component"
> required="false" />
> <cfargument name="questionBean" type="question"
> required="false" />
> <cfset var answerBean =
> variables.instance.transfer.new("question.Answer") />
> <cfif len(AnswerText)><cfset
> answerBean.setAnswerText(answerText) /></cfif>
> <cfif len(AnswerOption)><cfset
> answerBean.setAnswerOption(answerOption) /></cfif>
> <cfif len(Rating)><cfset answerBean.setRating(rating)
> /></cfif>
> <cfif len(PosterIP)><cfset
answerBean.setPosterIP(PosterIP)
> /></cfif>
> <cfif len(PostDate)><cfset
answerBean.setPostDate(PostDate)
> /></cfif>
> <cfif StructKeyExists(arguments,"questionBean") AND
> isObject(questionBean)>
> <cfset answerBean.setParentQuestion(questionBean)>
> </cfif>
> <cfif StructKeyExists(arguments,"userBean") AND
> isObject(userBean)>
> <cfset answerBean.setUser(userBean)>
> </cfif>
> <cfreturn answerBean />
> Cheers,
> James.
> -----Original Message-----
> From: transfer-dev@googlegroups.com
[mailto:transfer-dev@googlegroups.com]
> On Behalf Of Mark Mandel
> Sent: 05 May 2008 14:50
> To: transfer-dev@googlegroups.com
> Subject: [transfer-dev] Re: Caching of new objects that aren't persisted
> James,
> New objects aren't cached... so.. I'm not sure what you are driving at
here?
> Unless your 'save' is running, regardless of if your validate() has
failed?
> Mark
> On Mon, May 5, 2008 at 8:23 AM, James Allen <slingsho...@googlemail.com>
> wrote:
> > Hi guys,
> > Quick question that probably has an easy answer but..
> > When I am creating a new object in Transfer, I transfer.new() it, fill
> > it with data, validate and then save.
> > However, if validation fails the new object is kept in the transfer
> > cache. Therefore, the item appears on the website before it's been
> > saved.
> > What is the correct way to create a new object and only have it appear
> > once it's been persisted?
> > I was thinking maybe transfer.new() and then cloning the object. Would
> > that be the right way to do it?
> > Thanks in advance,
> > James.
> --
> E: mark.man...@gmail.com
> W: www.compoundtheory.com
--
E: mark.man...@gmail.com
W: www.compoundtheory.com