You'll have to searialize the sub-CFCs indivudually.

So you'll actually want something like this (forgive the mixed syntax,
typing tags for everything takes too long):

function serialize() {
  result = structNew();
  result.CFC = structNew();
  result.nonCFC = structNew();
  for (i in variables) {
    if (isObject(variables[i], "WEB-INF.cftags.component")) {
      result.CFC[i] = variables[i].serialize();
    } else {
      result.nonCFC[i] = variables[i];
    }
  }
  <cfwddx action="cfml2wddx" input="#result#" output="temp" />
  return temp;
}

Your deserialize() function would have to change as well, of course, but
would follow a similar pattern.


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Behalf Of Justin Balog
> Sent: Tuesday, September 23, 2003 4:14 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: [CFCDev] Serialize?
>
>
> That's a cool idea, will the variable ref work if your cfc is composed of
> cfcs?  Or will I have to serialize them individually?
>
>
> Thanks,
>
> Justin
>
> -----Original Message-----
> From: Barney Boisvert [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 23, 2003 4:58 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] Serialize?
>
>
> You can't serialize an entire CFC directly, because it's made up of more
> than just data.  The way I'd do it is to have a serialize() and
> deserialize() method in your CFC.  The first will take the CFC's internal
> state, wrap it up in whatever way you deem fit, and return a WDDX
> packet of
> that data, which can be stored however.  The deserialize() method
> would take
> that WDDX packet, and revert the CFC to the stored state.  If you're using
> 6.1, you should be able to just do the whole variables scope.
>
> <cfcomponent name="Serializer">
>   <cffunction name="serialize" ...>
>     <cfset var result = "" />
>     <cfwddx action="cfml2wddx" input="#variables#" output="result" />
>     <cfreturn result />
>   </cffunction>
>
>   <cffunction name="deserialize" ...>
>     <cfargument name="data" ... />
>     <cfset var temp = "" />
>     <cfset var i = "" />
>     <cfwddx action="wddx2cfml" input="#arguments.data#" output="temp" />
>     <cfloop collection="#temp#" item="i">
>       <cfset variables[i] = temp[i] />
>     </cfloop>
>   </cffunction>
>
>   <!--- other methods --->
> </cfcomponent>
>
> To use it, you'd do something like this:
>
> <cfscript>
> one = createObject("component", "Serializer");
> one.init();
> one.doSomething();
> wddx = one.serialize();
>
> two = createObject("component", "Serializer");
> two.deserialize(wddx);
>
> // now 'two' has the exact same state as 'one'
> </cfscript>
>
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> > Behalf Of Justin Balog
> > Sent: Tuesday, September 23, 2003 3:34 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: [CFCDev] Serialize?
> >
> >
> >
> > I don't even know if I am using the correct term?  Is there a
> quick way to
> > serialize a cfc, say in to a WDDX packet?  Basically, I want to take an
> > instance of a cfc and write it to a file in a meaningful way
> (i.e. WDDX or
> > XML) in case there is a dB error or ODBC connection failure.
> Any thoughts
> > on how to do this without having to call all the getters/setters of the
> > object itself.
> >
> >
> > Thanks,
> >
> > Justin
> > ----------------------------------------------------------
> > You are subscribed to cfcdev. To unsubscribe, send an email
> > to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> > in the message of the email.
> >
> > CFCDev is run by CFCZone (www.cfczone.org) and supported
> > by Mindtool, Corporation (www.mindtool.com).
> >
> > An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
>
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
> www.mail-archive.com/[EMAIL PROTECTED]
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to