When using indexed properties that go more than one level deep I've found that it's better to manually build the indexed property name using scriptlets or EL expressions rather than trusting the nested:xxx tags or the indexed="true" attribute. These just don't always work the way you want them to. Here's an example:
The above assumes that you either have a Servlet Version 2.4 application, or that you are using the struts-el version of the tags. You could accomplish the same thing with scriptlets.
[ServletException in:/customizeItn.jsp] No getter method for property properties.modules.properties.value of bean modules'
Is it correct?
I also have another question...As it is right now the values of the fields are not getting passed when the form is submitted. How can I pass the values to the servlet without passing hidden fields? It seems as if the set method is never getting called when I submit. Also, if this is achieved would I not have to worry about the indexing problem? Would the code use the correct set methods in the nested beans?
Joined: Feb 15, 2005
First of all, when manually building indexed property names, never use <nested:text>, but <html:text> instead. The nested tags manipulate the property name, and the whole point of manually building the property name is to do it right yourself and avoid "under the covers" manipulation that is not working right.
In answer to your second question: If you get the indexed property name right and have created indexed getters in your form beans, then the values will be propagated to the form correctly. For more information and examples on indexed properties, see question 6 of this forum's FAQ.
Joined: Oct 23, 2007
Thank you very much for your suggestions and replies to my questions. I was able to successfully index and set the different properties in my nested structure.
Here is what I did.
The three levels are as follows... DatabaseItn MBean PBean In DatabaseItn I needed to implement the ListUtils.lazylist feature in the reset method. In MBean I implemented the indexed get method for the properties field. And in PBean the fields were accessed correctly.
As for my jsp code I referenced the DatabaseItn form in the name attribute of the html/nested:text tag while using the scriptlet in the property attribute to correctly reference the index and field that I wanted. Here is how my jsp code looks.
I suppose "answers" is an implementation of java.util.Set Interface. There is no indexed getter for this kind of object. Try using an implementation of the java.util.List interface.
Joined: Feb 15, 2005
Thanks for taking the time to change your display name. However, you're not quite there yet. The JavaRanch Naming Policy requires that you display both a first and last name. If you don't want to display your real name, that's fine, but the name you display must at least appear to be a real name.