Stephen and Duncan - thanks for your help.
Without this mailing list (and all the helpful people using it) I'd be a lot
more stressed out. There don't seem to be many CF developers in my area who
I can talk this stuff over with. Anyay, back to the problem in hand.
I am trying to create an associative array - I think this is what a Struct()
is: an array with keys rather than positions - and store information in it
from user input across several stages / pages.
It is not a shopping basket but it shares similar business rules, i.e., one
stage cannot be started unless another has been completed. This is also true
for validation of the business rules. The stages may change order now and
again.
I don't want to rely upon client side variable because my application won't
work at all if cookies are disabled. Not good here and this is not an
application for an Intranet.
The information to be persisted will change in design regularly.
I have just had a go at using:
<cfparam name="session.someStruct" type="struct">
<cfset session.someStruct.nestedStruct = StructNew()>
<cfset session.someStruct.nestedStruct.val1 = "hello Sam">
<!--- test everything so far --->
<cfoutput>The content of val1 is
#session.someStruct.nestedStruct.val1#<br></cfoutput>
<!--- serialise the struct --->
<cfwddx action="cfml2wddx" input="#session.someStruct#"
output="structInXML">
It seems to work fine - deserialising is just as easy. I doesn't matter
changes are made to structure - as long as the root struct retain the same
handle/name - there is now a layer of seperation between the data and the
application.
I guess one of the drawbacks of this technique is that some DB fields will
need to be large. Another problem might be that you can end up storing
information that is not needed (i.e., fluff in the structure) but I guess
good design can reduce this.
The advantages seem to be that it seperates the business logic from the data
stoarge and makes updating the code quicker and easier.
Do you guys think this makes sense or am I approaching this from the wrong
angle?
All comments gratefully received!
Sam
-----Original Message-----
From: Stephen Moretti [mailto:[EMAIL PROTECTED]
Sent: 09 April 2004 11:39
To: [EMAIL PROTECTED]
Subject: Re: [ cf-dev ] Serialise a Structure?
Sam Westlake wrote:
> Sorry - not very accurate with my first question. The user will have
> an option to persist the structure state using some sort of HCI event
> - button click - and then persist the structure.
>
> Is this when <cfwddx> comes into play?
Yes it would be. Although I'm not sure what happens to a struct that is
serialised/deserialised.
However, as Duncan said, how are you going to know when the session ends.
Closing the browser or inactivity timeout will both leave the application
with no trace that the session has ended.
What is it that you're actually trying to cache? Some kind of "shopping
cart"?
Have you thought about using client variables (default 90days
persistence) and a less complex data structure? With stuff like this I
usually handle with simple lists in the form :
itemid | quantity | comment � itemid | quantity | comment Its pretty
painless and quick to convert the lists to/from an array or structure or use
them as they are.
Hope that helps.
Regards
Stephen
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided
by activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by
proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by
gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]
--
These lists are syncronised with the CFDeveloper forum at
http://forum.cfdeveloper.co.uk/
Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by
activepdf.com*
*Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
*Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*
To unsubscribe, e-mail: [EMAIL PROTECTED]