PDA

View Full Version : input name encoding problem


bernardsirius
04-03-2005, 12:16 AM
Hi,

I'm using the spring framework (http://www.springframework.org/) at the backend, and I'm trying to take advantage of their nested binding mechanism.

Spring makes it possible to automatically bind request parameters to object (bean-) properties. This is done using the well-known javaBeans pattern, where object.property stands for "the property named 'property' of the 'object' bean".

For collection properties, Spring uses Maps: you can attach a Hashtable to your bean; let's say you have a Person Bean and Address objects attached to it... in Spring you would have a Hashtable 'addresses' property, with keys like 'Home', 'Work', etc...

Then to bind a particular address with request parameters, you would name your parameters with square brackets:
addresses[Work], addresses[Home]...

Yes BUT laszlo apparently prevents the use of brackets: I consistently get form parameters ending with a question mark, like this:

addresses[Work?, addresses[Home?

...which completely breaks my plans to use this very handy mechanism of spring's...

Do you guys know how to have my square brackets straight?

bernard

hqm
04-03-2005, 05:38 AM
I don't understand what the situation is that you're describing? Is this is a problem with query strings for data requests? For XML content coming back?

Can you put a simple test case up here that I can run so I can try to reproduce the problem?

thanks

bernardsirius
04-03-2005, 11:08 PM
sure, here is a little test case:

<canvas bgcolor="red" debug="true" width="1024" height="768">
<include href="base/style.lzx"/>
<debug y="300"/>

<dataset name="testformds" type="http" src="http://localhost:8080/psychos/testform.action"/>

<view layout="axis:y;spacing:10" width="250">
<form width="${parent.width}">
<view layout="axis:x;spacing:3" width="${parent.width}" bgcolor="blue">
<statictext>First name</statictext>
<edittext align="right" name="firstname"/>
</view>
<view layout="axis:x;spacing:3" width="${parent.width}">
<statictext>Last name</statictext>
<edittext align="right" name="lastname"/>
</view>
<view layout="axis:x;spacing:3" width="${parent.width}">
<statictext>e-mail</statictext>
<edittext align="right" name="email"/>
</view>
<view layout="axis:x;spacing:3" width="${parent.width}">
<statictext>Work phone</statictext>
<edittext align="right" name="phone[Work].address"/>
</view>
<view layout="axis:x;spacing:3" width="${parent.width}">
<statictext>Home phone</statictext>
<edittext align="right" name="phone[Home].address"/>
</view>
<submit name="submit" data="${testformds}"/>
<button text="Send" onclick="parent.submit.submit()"/>
</form>
</view>
</canvas>

Now, this is what I get from the HTTP monitor of my IDE (NetBeans) (all fields being left blank):
Query string: phone[Home?.address=&phone[Work?.address=&email=&lastname=&firstname=

notice the ']' have become '?'

BTW, how come the edit texts are not right aligned ? I have specified a blue background for one of their enclosing views, to verify it has room at its right (where is should be placed), so why doesn't it work?

bernard