aspose file tools*
The moose likes Struts and the fly likes Struts1: queryString with indexed properties not parsed correctly Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts1: queryString with indexed properties not parsed correctly" Watch "Struts1: queryString with indexed properties not parsed correctly" New topic
Author

Struts1: queryString with indexed properties not parsed correctly

Tim Kernan
Greenhorn

Joined: Aug 25, 2010
Posts: 16
I am unable to get() the indexed properties contained in a query string from a submitted page.

It appears that the Bean parser (or some parsing function) is skipping over or is confused by the % sign. Non indexed properties are parsed just fine.
I am using Struts 1.3.8, Netbeans 6.7.1, jdk1.6.0_16 on a Linux OS, Browser = FireFox 1.5.0.7

1. HTML form has input fields of this format:
<input type="text" name="lines[0].town" value="dilton"></td>

2. The query string is: (as obtained by request.getQueryString() :
"test=5&testb=6&lines%5B0%5D.name=tim&test=4&lines%5B0%5D.town=milton&lines%5B1%5D.name=tom&test=4&lines%5B1%5D.town=wilton&lines%5B2%5D.name=todd&test=4&lines%5B2%5D.town=dilton&lines%5B3%5D.name=ted&test=4&lines%5B3%5D.town=hilton&operation=Submit&ams=1258

3. All properties which do not contain the % sign are parsed properly by the ActionForm.

4. It seems to me that Struts must be able to deal with these or have a way to convert the %5B to { and %5D to ].

You assistance is much appreciated.
Thanks
Tim
Sriram Ture
Greenhorn

Joined: Aug 20, 2010
Posts: 23
Hi,


You can do it in a better way. Just go through the link below.

Data Retention



Regards,
Sriram
Tim Kernan
Greenhorn

Joined: Aug 25, 2010
Posts: 16
Sriram
Thanks for refering me to that article. Unless I am missing something, the article presented a "typical" indexed property example of both JSP code and the bean ActionForm getters and setters.Altho, it avoided the use of <html:test .../> to construct the page.
This is indeed the model I am using. The problem is that the % signs used in the query string returning to the ActionForm are preventing the indexed objects from being parsed. Thus the setter methods are not invoked.


Here is the JSP code


Here is the resulting query string:
test=5&testb=6&lines%5B0%5D.name=tim&test=4&lines%5B0%5D.town=milton&lines%5B1%5D.name=tom&test=4&lines%5B1%5D.town=wilton&lines%5B2%5D.name=todd&test=4&lines%5B2%5D.town=dilton&lines%5B3%5D.name=ted&test=4&lines%5B3%5D.town=hilton&operation=Submit&ams=1258

The indexed properties (ie ines%5B0%5D.name=tim )are not being parsed, I presume because of the % sign. The following method is never invoked:



Question:
1) Do I need to set a <form-property > in struts-config.xml to handle indexed propertiesin the ActionForm?

2) How do I tell my browser (Firefox) ont to encode the brackets [ and ]? I presume that is the source of the problem.

3) How do I tell Struts to decode the %5d %5b characters before the request is parsed?

4) Am I making the wrong assumptions as to where the problem is?

Thanks again for your help on this problem.
Tim

Sriram Ture
Greenhorn

Joined: Aug 20, 2010
Posts: 23
Tim,


There is no problem with the parsing stuff. Can you paste your form class.



Tim Kernan
Greenhorn

Joined: Aug 25, 2010
Posts: 16
Sriram
Thanks for you help on this, it is driving me nuts.
Here is my ActionForm class:

-Tim




Also here is a copy of simple Line

Sriram Ture
Greenhorn

Joined: Aug 20, 2010
Posts: 23
Hi,

This will work fine for you.




Regards,
Sriram
Tim Kernan
Greenhorn

Joined: Aug 25, 2010
Posts: 16
Sriram
javascript:emoticon('');
IT worked!!!
I understand the code, but not why it worked. It seem that the key was:
public Line getLines(int index) VS public Line getLines(Integer index)

I persume that without this the BeanUtils parser could not identify the signature of the method to call??

THANKS A TON!!!

-TIm


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts1: queryString with indexed properties not parsed correctly