Whoops-- that's a 'logical typo' that I made when writing this
simplified (and untested) version of my problem. Here's the
corrected scenario:
dim ObjectArray
dim PersonObject
ObjectArray = newCollection.Items
set PersonObject = ObjectArray(0)
Response.Write PersonObject.age ' uh, "boom"; the "PersonObject"
does not support the "age" method or property.
--- In padnug@xxxxxxxxxxxxxxx, blackbeltsolutions <no_reply@xxxx>
wrote:
>
> > ' A check on failedObj shows that it is not null-- it is set to
an
> > object.
> >
> > Response.Write failedObj.age
> >
> > ' Boom! A "Object does not support this method or property"
error
> > occurs here. "FailedObj" appears not to be "cast" as a type.
> >
> >
>
> In this section you use failedObj.age when the class defines nAge...
>
>
> --- In padnug@xxxxxxxxxxxxxxx, "Perry Pederson" <perandtim@xxxx>
> wrote:
> >
> > I've stumbled onto an asp problem at work where I'm cleaning up a
> ton
> > of code, and needed to store some ASP 'class' data types (a user
> > defined type consisting of variant variables) in a
> ASP "dictionary",
> > which serves as a "collection" container.
> >
> > All was going well until I found out that I needed to persist the
> > contents of the collection container across a ASP page reload. I
> > stored the collection into the Session object and can restore it
> from
> > the Session object without problems. The (restored) container
> shows
> > that it has the "original" keys and number of "class" data types
> > stored in the container, but when I attempt to access a "member"
> of
> > the class data type, I get a "Object does not support this method
> or
> > property" error. Since I can't do a cast in ASP, I'm not sure
how
> to
> > restore the class objects, unless I hack a form of serialization
> into
> > the code.
> >
> > In case it's difficult to follow my description, here's a simple
> > version of what I'm doing:
> >
> > (ASP, not ASP.NET):
> >
> > class person
> > dim nAge
> > end class
> >
> > dim Jane
> >
> > Jane = new person
> > Jane.nAge = 42
> >
> > dim objCollection
> > set objCollection = Server.CreateObject("Scripting.Dictionary")
> >
> > objCollection.Add "Person1", Jane
> >
> > ' Example: Jane can be restored out of the collection:
> >
> > dim aPerson
> >
> > set aPerson = objCollection.Item("Person1")
> >
> > Response.Write aPerson.nAge
> >
> > ' 42 is printed out-- proof that Jane's data can be obtained out
> of
> > the collection.
> >
> > Session("Preserved_Dictionary") = objCollection ' store the
> collection
> >
> > [ ASP page reloads; objCollection is disposed. Attempt to
restore
> > the info stored in the Session object ]
> >
> > dim newCollection
> >
> > set newCollection = Session("Preserved_Dictionary")
> >
> > Response.Write newCollection.Count
> >
> > ' 1 is printed; the new collection contains one object
> >
> > ' Additional proof that the newCollection contains info:
> >
> > dim svar
> > dim keys
> >
> > svar = gdictSVAInfo.Items
> > keys = gdictSVAInfo.Keys
> >
> > for i = 0 to newCollection.Count-1
> >
> > Response.Write "#" & i & " k: " & keys(i) & ": "
> >
> > if isnull(svar(i)) then
> > Response.Write "null"
> > else
> > Response.Write "not null"
> > end if
> >
> > Response.Write "<br>"
> >
> > next
> >
> > ' output is "#0 k: Person1: not null"
> >
> > ' Cool! The object exists, the key (Person1) was restored, let's
> use
> > it!
> >
> > dim failedObj
> >
> > set failedObj = newCollection.Item("Person1")
> >
> > ' A check on failedObj shows that it is not null-- it is set to
an
> > object.
> >
> > Response.Write failedObj.age
> >
> > ' Boom! A "Object does not support this method or property"
error
> > occurs here. "FailedObj" appears not to be "cast" as a type.
> >
> >
> > Attempts to cast to a "class" type don't work, as all variables
in
> > ASP are variants and only base type converstions (CStr, CBool,
> etc.)
> > are supported.
> >
> > Any help on this rather odd case would be very much welcome!
> >
> > Thanks for reading,
> >
> > Perry
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/dpFolB/TM
--------------------------------------------------------------------~->
|