File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Indexed Properties with List of Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Indexed Properties with List of Strings" Watch "Indexed Properties with List of Strings" New topic

Indexed Properties with List of Strings

Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
I was trying to get an indexed properties example working where my form contains a List of String object but I could not. Here is my form and the method signatures:

I have tried a couple things in the jsp, but here is what seems to be the closest:

This causes this error when the page is displayed:

No getter method for property: "phoneItem" of bean: "my.examples.indexed.SimpleIndexedForm"

If I build the index myself using some scriptlet code, it works fine.

Got any tips on making this work?

- Brent
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
My understanding is that indexed="true" works only for a List or array of JavaBeans. It does not work for a String array. For that, one has to do as you have done and manually construct the indexed property using either scriptlets or EL expressions.
[ October 15, 2007: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
That is all I could figure out as well...just wanted to make sure that I was not missing something. I played around with my sample code and the best solution that I could come up for someone that really wanted to use the indexed="true" setting is to create a StringWrapper class that just had a String property named value.

On a side note...I should play around more with Struts EL. It is looking like my project will be stuck with JSP 1.2 support for a while and there are plenty of places where using EL would be handy.

- Brent
I agree. Here's the link:
subject: Indexed Properties with List of Strings
It's not a secret anymore!