Merrill
Consultant, Sima Solutions
Originally posted by Brent Sterling:
Looking at the JSP code that you posted, it looks basically correct. It seems like the name attributes on your notEmpty tags and iterate tags should be the same. Maybe it would help if you posted your ActionForm code. The snippet of Java code that you posted does not seem to match up with the JSP. Your JSP would translate into Java code like this (I think):
prodSelection.getCounter(index).getNumProducts();
- Brent
Originally posted by Merrill Higginson:
It appears that you don't have a clear understanding about how indexed properties work in Struts. Here are a couple of links that should give you an idea of how they work:
http://struts.apache.org/1.2.9/faqs/indexedprops.html
http://wiki.apache.org/struts/StrutsCatalogLazyList
If you still have questions, let us know.
Struts html tags have an indexed attribute which will generate the appropriate html to populate a collection of beans when the form is submitted. The trick is to name the id attribute to the same as the indexed property.
Merrill
Consultant, Sima Solutions
Thanks for showing us your Action class code, but it's actually the code in your ProdSelectionForm that we're more interested in. It's the coding of the methods of this class that can prevent you from getting that "Index out of bounds" exception.
Incidentally, one solution that we haven't discussed much is changing your action mapping so that the ActionForm is in session scope. This will also eliminate the "Index out of bounds" exception. Brent and I tend to disagree somewhat on this issue, but I think it's perfectly OK to store the ActionForm in the session, particularly in cases where the model being represented by the ActionForm is complex and multi-layered. If you do this, it's important to remove the object from the session once you're done with it in order to keep memory usage under control.
Merrill
Consultant, Sima Solutions
Originally posted by Merrill Higginson:
If you just want to get this working, change the action mapping in your struts-config.xml file to specify scope="session". That should keep you from getting the "Index out of bounds" exception.
Once you've got it working, if you decide it's important to you to have the form in request scope, study the link that I gave you carefully, and you'll understand how to give your AcgtionForm lazy initialization behavior.
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|