I have been developing an app that needs to send large amounts (~kilobytes)
of structured data between the server and the client.  I have been working
on a framework to facilitate this by using JavaScript's object notation.

Essentially, I have a JavaScript function that converts a JavaScript object
or array into it's string representation.  This string is then placed in a
hidden field and posted to the servlet.  The servlet then reads the field
and decomposes the string into an object hierarchy composed of strings,
floats and Booleans either singularly (addressable by name) or in an array.

The client-side is very small.  It consists of a single JavaScript function
that creates the string.  The servlet-side piece requires several class
files which I have placed in a package.

At this time there is very little (read: no) documentation and it is
probably not the most efficient code, but for the most part it works.  The
only known current limitation is the inability to handle nulls.

Please keep in mind that for small amounts of data, this would be overkill.
By the time you define the structure of the objects being passed you could
have written and debugged the code to add a dozen or so hidden fields and
process them in the servlet.  But in my case I need to pass an object that
contains multiple, variable-length arrays, some containing another object.
Trying to do this by adding hidden fields through the DOM was getting ugly,
so I came up with this.

If you or anyone else is interested I could post both the client and server
side code, but I would need to tie up a few loose ends before subjecting
myself to a code review.  :0)  I also need to write up a page or two of
documentation (something I need to do anyway), so it may take a day or two.

Mark



-----Original Message-----
From: Henry [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 07, 2002 2:11 AM
To: [EMAIL PROTECTED]
Subject: client side object to server side


I have defined some client side objects using javascript, these objects'
number and value varies during the interaction with users. But when the user
submit the form, I want an easy way to send the objects to the server
(servlet, say).

I am wondering this is doable by having a hidden field which the value is
the object (rather than a string or a number)?

thanx in advance.

--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to