ooh really cool stuff.  Thanks Nando and John (and Bob).  That looks
like a nice solution, Nando.

I've read Bob's full excellent series and do have my abstract
decorators in place... now it's just a matter of starting to move some
functionality into them :)

On Jan 7, 1:22 pm, Nando <[email protected]> wrote:
> I use an AbstractDecorator:
>
> <cfcomponent displayname="AbstractDecorator" output="false"
> extends="transfer.com.TransferDecorator">
>
>     <cffunction name="setInstanceFromStruct">
>         <cfargument name="data" required="true" type="struct"
>                     hint="The struct containing the data to set." />
>         <cfloop index="i" list="#StructKeyList(arguments.data)#">
>             <cfinvoke method="set#i#">
>                 <cfinvokeargument name="#i#"
> value="#trim(arguments.data[i])#" />
>             </cfinvoke>
>         </cfloop>
>     </cffunction>
>
> </cfcomponent>
>
> Then each transfer object has a decorator that extends the
> AbstractDecorator, like so:
>
> <cfcomponent displayname="HerbDecorator" output="false"
> extends="AbstractDecorator">
>
>     <cffunction name="configure" access="public" output="false">
>         <cfset setValidationResult(true)>
>         <cfset setInvalidFields('')>
>         <cfset setMissingFields('')>
>     </cffunction>
>
>     <cffunction name="validate" returntype="void" access="public"
> output="false">
>
> ....
>
> </cfcomponent>
>
> Bob's populate method is much more complex, as I remember.
>
> Nando
>
> On Wed, Jan 7, 2009 at 6:30 PM, Brian FitzGerald
> <[email protected]>wrote:
>
>
>
>
>
> > sorry Josh, I should've provided more info.  It might look something
> > like this:
>
> > var properties = getTransferObjectProperties(transferBean);
> > var i = 1;
> > var thisProperty = "";
>
> > for(i = 1; i lte arrayLen(properties); i++) // call the setter for
> > each property in the object
> > {
> >    thisProperty = properties[i].name;
> >    if(structKeyExists(arguments.args, thisProperty))
> >    {
> >      evaluate( "transferBean.set" & thisProperty & "('" &
> > arguments.args[thisProperty] & "')"  );
> >    }
> > }
>
> > On Jan 7, 12:26 pm, Brian FitzGerald <[email protected]>
> > wrote:
> > > Hey Josh, yeah that's something I wrote...
>
> > > On Jan 7, 12:21 pm, "Josh Nathanson" <[email protected]> wrote:
>
> > > > Is that "populate" method something you cooked up, or is that native to
> > > > Transfer?  I can't find it anywhere in the docs.
>
> > > > -- Josh
>
> > > > -----Original Message-----
> > > > From: [email protected] [mailto:
> > [email protected]]
>
> > > > On Behalf Of Brian FitzGerald
> > > > Sent: Wednesday, January 07, 2009 9:03 AM
> > > > To: transfer-dev
> > > > Subject: [transfer-dev] Re: back button update transfer object
>
> > > > Thanks for the ideas fellas!
>
> > > > I ended up just "re-grabbing" the TO in the scenario that it already
> > > > existed in the db and then populating it w/ the form data:
>
> > > > if( exists(quizResult) )
> > > > {
> > > >    persistedQuizResult = transfer.get("quiz.QuizResult",
> > > > quizResultId);
> > > >    persistedQuizResult.populate(qrDataFromForm);
> > > >    transfer.update(persistedResult);
> > > > }
>
> > > > else
> > > > {
> > > >   transfer.create(quizResult);
> > > > }
>
> > > > This way the QuizResult knew it was persisted so when I went to run an
> > > > update it didn't have any problem.
>
> > > > Thanks again,
> > > > Brian
>
> > > > On Jan 6, 7:16 pm, "Mark Mandel" <[email protected]> wrote:
> > > > > That is true.. you could preset the ID of the object... therefore if
> > > > > you go back, you know what it should be the 2nd time around... that
> > > > > would work.
>
> > > > > Mark
>
> > > > > On Wed, Jan 7, 2009 at 11:14 AM, Alan Livie <[email protected]>
> > wrote:
> > > > > > Not Transfer related but if you use a UUID as a hidden form field
> > and
> > > > save
> > > > > > this too if a form is re-submitted you can ignore the insert IF the
> > UUID
> > > > > > already exists in the database.
>
> > > > > > ________________________________
> > > > > > From: Dan Wilson <[email protected]>
> > > > > > To: [email protected]
> > > > > > Sent: Tuesday, January 6, 2009 8:54:05 PM
> > > > > > Subject: [transfer-dev] Re: back button update transfer object
>
> > > > > > How I handle it in 95% of cases is do a redirect to a neutral page
> > once
> > > > the
> > > > > > form was successfully submitted.
>
> > > > > > <cflocation> for the win!
>
> > > > > > dw
>
> > > > > > On Tue, Jan 6, 2009 at 3:47 PM, Mark Mandel <[email protected]
>
> > > > wrote:
>
> > > > > >> Brian,
>
> > > > > >> This is more of an application design / user training question.
>
> > > > > >> If a user hits the back button, then they go back to the 'create
> > new'
> > > > > >> screen... which has no idea what was previously entered.
>
> > > > > >> So if they hit submit again, your app has no way to know what
> > their
> > > > > >> last insert was.
>
> > > > > >> How you handle this, I think is going to be really up to the needs
> > of
> > > > > >> your application.
>
> > > > > >> Mark
>
> > > > > >> On Wed, Jan 7, 2009 at 6:15 AM, Brian FitzGerald
> > > > > >> <[email protected]> wrote:
>
> > > > > >> > Hey guys, any thoughts are appreciated ...
>
> > > > > >> > When a user submits a quiz, my QuizResult transfer object is
> > saved -
> > > > > >> > transfer.save(QuizResult)
>
> > > > > >> > The problem occurs when the user hits "back" to fix their
> > answers and
> > > > > >> > resubmit ... at this point transfer runs save again, but instead
> > of
> > > > an
> > > > > >> > update, it tries to do another create.  This generates a SQL
> > error
> > > > > >> > since it tries to insert a duplicate record ... the TO doesn't
> > > > realize
> > > > > >> > it's already persisted
>
> > > > > >> > in order to force transfer to run create or update in the
> > correct
> > > > > >> > scenario, I stuck in an "exists" method ...
>
> > > > > >> > if( exists(quizResult) )
> > > > > >> > {
> > > > > >> >   transfer.update(quizResult);
> > > > > >> > }
> > > > > >> > else
> > > > > >> > {
> > > > > >> >  transfer.create(quizResult);
> > > > > >> > }
>
> > > > > >> > but this is still giving me problems because, after hitting the
> > back
> > > > > >> > button, the transfer object still thinks it isn't persisted even
> > when
> > > > > >> > it is, so while it does run "update", it also blows up: "The
> > Transfer
> > > > > >> > Object of type 'quizResult.QuizResult' has not been created in
> > the
> > > > > >> > database"
>
> > > > > >> > Can anyone point me in the right direction on this?  Thanks in
> > > > advance
>
> > > > > >> --
> > > > > >> E: [email protected]
> > > > > >> W:www.compoundtheory.com
>
> > > > > > --
> > > > > > "Come to the edge, he said. They said: We are afraid. Come to the
> > edge,
> > > > he
> > > > > > said. They came. He pushed them and they flew."
>
> > > > > > Guillaume Apollinaire quotes
>
> > > > > --
> > > > > E: [email protected]
> > > > > W:www.compoundtheory.com
>
> --
>
> Nando M. Breiter
> The CarbonZero Project
> CP 234
> 6934 Bioggio
> Switzerland
> +41 76 303 4477
> [email protected]
--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
"transfer-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to