Big Thanks to All of you. I got it working with a wrapper class. I
included my code below so future searches on this problem can get
running quickly.
var myLocal_so:SharedObject;
function writeIt(result:Array):Void
{
myLocal_so = SharedObject.getLocal("mySO");
// custom Wrapper class
var myDP:SharedObjectDP = new SharedObjectDP();
myDP.setDataProvider(result);
myLocal_so.data.dataProvider=myDP;
myLocal_so.flush();
}
<mx:DataGrid id="dg" dataProvider="{mx.utils.ArrayUtil.toArray
(myLocal_so.data.dataProvider.dataProvider)}" ..../>
<mx:RemoteObject source="com.MyService" ..>
<mx:method name="getAllPojos" result="writeIt(event.result)" />
</mx:RemoteObject>
/* Implementation Wrapper class */
class com.SharedObjectDP extends Object {
public function SharedObjectDP(){}
var dataProvider: Array;
function getDataProvider() : Array { return dataProvider; }
function setDataProvider(arg : Array) : Void { dataProvider = arg; }
}
--- In [email protected], "Alistair McLeod" <[EMAIL PROTECTED]>
wrote:
> Hi Kevin,
>
> The flex docs say this.
>
> "Because the SharedObject object is built into Flash Player, its
behavior
> cannot be modified by the binding mechanism. To use binding with a
> SharedObject, you must write a wrapper object that uses a
SharedObject
> object internally, but has getter/setter properties that the rest
of your
> application can use. If you do not use a wrapper object, a
SharedObject
> appears to lose data, specifically data that might have been used
in a
> binding expression."
>
> http://livedocs.macromedia.com/flex/15/flex_docs_en/00000696.htm
>
> Cheers,
>
> Ali
>
> --
> Alistair McLeod
> Development Director
> iteration::two
> [EMAIL PROTECTED]
>
> Office: +44 (0)131 338 6108
>
> This e-mail and any associated attachments transmitted with it may
contain
> confidential information and must not be copied, or disclosed, or
used by
> anyone other than the intended recipient(s). If you are not the
intended
> recipient(s) please destroy this e-mail, and any copies of it,
immediately.
>
> Please also note that while software systems have been used to try
to ensure
> that this e-mail has been swept for viruses, iteration::two do not
accept
> responsibility for any damage or loss caused in respect of any
viruses
> transmitted by the e-mail. Please ensure your own checks are
carried out
> before any attachments are opened.
>
>
> -----Original Message-----
> From: [email protected]
[mailto:[EMAIL PROTECTED] On
> Behalf Of Alistair McLeod
> Sent: 03 June 2005 14:55
> To: [email protected]
> Subject: RE: [flexcoders] Re: Saving a datagrid.dataProvider to a
> SharedObject
>
> Hi Kevin,
>
> Due to the way binding is implemented (it adds implicit setters
and getters
> for the properties), there are known issues in binding to data in
shared
> objects - its mentioned in the docs somewhere. Bascially, you'll
have to
> clone the object properties before you write them to the shared
object
> and/or read them back from the shared object.
>
> Cheers,
>
> Ali
>
>
> --
> Alistair McLeod
> Development Director
> iteration::two
> [EMAIL PROTECTED]
>
> Office: +44 (0)131 338 6108
>
> This e-mail and any associated attachments transmitted with it may
contain
> confidential information and must not be copied, or disclosed, or
used by
> anyone other than the intended recipient(s). If you are not the
intended
> recipient(s) please destroy this e-mail, and any copies of it,
immediately.
>
> Please also note that while software systems have been used to try
to ensure
> that this e-mail has been swept for viruses, iteration::two do not
accept
> responsibility for any damage or loss caused in respect of any
viruses
> transmitted by the e-mail. Please ensure your own checks are
carried out
> before any attachments are opened.
>
>
> -----Original Message-----
> From: [email protected]
[mailto:[EMAIL PROTECTED] On
> Behalf Of Kevin Ewok
> Sent: 03 June 2005 14:19
> To: [email protected]
> Subject: [flexcoders] Re: Saving a datagrid.dataProvider to a
SharedObject
>
> Matt, thanks for your response. I did what you suggested, but now
my
> datagrid is only populated with the last object of my dataset.
When i
> debugged my local SharedObject, I see that this is true (my
> so.data.dataProvider only has 1 (the last) object in it). Can a
local shared
> object data.value truly hold an array of AS objects?
>
> FYI to everyone, I could only get it to display in my datagrid if
i added
> the 'toArray'. Either way, only the last of my 14 Pojos (which is
registered
> to an AS class) is getting saved to the local shared object.
>
> <mx:RemoteObject source="com.MyService"
> result="myLocal_so.data.dataProvider=event.result" .../>
>
> <mx:DataGrid id="dgSO" dataProvider="{mx.utils.ArrayUtil.toArray
> (myLocal_so.data.dataProvider)}" .../>
>
> Any suggestions are appreciated b/c i'm stuck. Thanks.
>
> --- In [email protected], "Matt Chotin" <[EMAIL PROTECTED]>
> wrote:
> > You need to save the result of the getAllJobs call in the result
> > handler, not the returned object from getAllJobs(). So in your
> result
> > handler of getAllJobs you can say myLocal_so.data.dataProvider =
> > event.result;
> >
> >
> >
> > Matt
> >
> >
> >
> > ________________________________
> >
> > From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> > Behalf Of Kevin Ewok
> > Sent: Thursday, June 02, 2005 2:23 PM
> > To: [email protected]
> > Subject: [flexcoders] Saving a datagrid.dataProvider to a
> SharedObject
> >
> >
> >
> > flexcoders-
> > I have a datagrid that is populated from an array of objects
> from
> > a remote method. My requirement is that if the user closes their
> > browser, and opens it back up, and there IS NOT a connection,
then to
> > load the datagrid from the locally stored data.
> >
> > I am able to save text strings locally and display it in labels,
> but
> > that is it. I am not able to store the Pojo[] result of my
> > remoteMethod or the AS dataprovider. Has anyone been able to do
this?
> > I was able to save an individual Pojo to a
sharedObject.data.item, but
> > not a collection. I guess I could loop through my dataProvider
and
> > create a sharedObject.data.item1,
> item2,
> > etc...for each dataProvider item, but I wanted to save some
logic.
> >
> > I've tried the following and I get undefined for my value in the
> SO.
> >
> > var myLocal_so:SharedObject;
> > myLocal_so = SharedObject.getLocal("mySo");
> >
> > ..//each line here represents a different failed attempt..//
> > myLocal_so.data.dataProvider=myRemoteObj.getAllJobs();
> > myLocal_so.data.dataProvider=mx.utils.ArrayUtil.toArray
> > (myRemoteObj.getAllJobs());
> > myLocal_so.data.dataProvider=myDatagrid.dataProvider;
> > myLocal_so.data.dataProvider=myDatagrid;
> > ..//...
> > myLocal_so.flush();
> >
> > Thanks in advance for your help.
> >
> >
> >
> >
> >
> >
> >
> >
> > ________________________________
> >
> > Yahoo! Groups Links
> >
> > * To visit your group on the web, go to:
> > http://groups.yahoo.com/group/flexcoders/
> >
> > * To unsubscribe from this group, send an email to:
> > [EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]
> subject=Unsubscribe>
> >
> > * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> > Service <http://docs.yahoo.com/info/terms/> .
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/