That's a pretty interesting idea.
If you registered a Converter (in BeanUtils) that knew how to convert
a String to a TestObject (and back), I'll bet you could get
BeanUtils.populate() to do what you want.
Craig
On Fri, 29 Oct 2004 13:07:49 -0400, Ed DeMaio <[EMAIL PROTECTED]> wrote:
> I have a javascript object that I store in a hidden form field. It
> seems to be submitted to the servlet as an array of strings, where the
> indices are the values of the properties of the javascript Object.
>
> Basically I'm wondering how I can have a javascript object mapped to a
> java object, instead of simply into an array of strings. It seems to
> have something to do BeanUtils.populate(), but really I'm not sure. If
> anyone can even point me in some vaguely helpful direction it would be
> much appreciated, as I have been searching for days.
>
> Below is an example in case my description was unclear...
>
> my jsp file includes:
>
> <script type="javascript">
> var test = new Object();
> test.property1 = "qwerty";
> test.property2 = 7;
>
> window.onload = function() {
> document.getElementById('form1').test.value = test;
> }
> </script>
>
> <html:form styleId="form1"......>
> <html:hidden property="test" styleId="test" />
> <html:submit property="submit" />
> </html:form>
>
> my ActionForm class contains the following getter and setter method:
>
> public TestObject getTest() { return testObj; }
> public void setTest(TestObject test) { this.testObj = test; }
>
> and my TestObject class contains the following getter and setter
> methods:
>
> public String getProperty1() { return prop1; }
> public void setProperty1(String s) { this.prop1 = s; }
>
> public Integer getProperty2() { return prop2; }
> public void setProperty2(Integer i) { this.prop2 = i; }
>
> and when the form is submitted, i would like the test object in my
> action form populated with the properties from the javascript test
> object that was submitted.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]