Google Groups Home
Help | Sign in
Caching of new objects that aren't persisted
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
James Allen  
View profile
 More options May 5, 9:23 am
From: James Allen <slingsho...@googlemail.com>
Date: Mon, 5 May 2008 06:23:01 -0700 (PDT)
Local: Mon, May 5 2008 9:23 am
Subject: Caching of new objects that aren't persisted
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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Mandel  
View profile
 More options May 5, 9:50 am
From: "Mark Mandel" <mark.man...@gmail.com>
Date: Mon, 5 May 2008 08:50:08 -0500
Local: Mon, May 5 2008 9:50 am
Subject: Re: [transfer-dev] 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

--
E: mark.man...@gmail.com
W: www.compoundtheory.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Allen  
View profile
 More options May 5, 10:17 am
From: "James Allen" <slingsho...@googlemail.com>
Date: Mon, 5 May 2008 15:17:41 +0100
Local: Mon, May 5 2008 10:17 am
Subject: RE: [transfer-dev] Re: Caching of new objects that aren't persisted
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.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Mandel  
View profile
 More options May 5, 12:16 pm
From: "Mark Mandel" <mark.man...@gmail.com>
Date: Mon, 5 May 2008 11:16:47 -0500
Local: Mon, May 5 2008 12:16 pm
Subject: Re: [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

--
E: mark.man...@gmail.com
W: www.compoundtheory.com

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
James Allen  
View profile
 More options May 5, 12:46 pm
From: "James Allen" <slingsho...@googlemail.com>
Date: Mon, 5 May 2008 17:46:28 +0100
Local: Mon, May 5 2008 12:46 pm
Subject: RE: [transfer-dev] Re: Caching of new objects that aren't persisted
Aha I see. Yeah I did think cloning might be the answer. I can't really do
the parent attaching at save because the save is carried out by the
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.

Cheers,
James.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google