File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes IndexOutOfBounds while submitting form. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "IndexOutOfBounds while submitting form." Watch "IndexOutOfBounds while submitting form." New topic
Author

IndexOutOfBounds while submitting form.

Kamal Tripathi
Ranch Hand

Joined: Oct 02, 2008
Posts: 86
I am getting IndexOutOfBounds exception while submitting form. I will try to explain as much as possible here and then hope for a solution.

Now first request is made when the page loads (say request1) and when the page loads AJAX call is made which loads the Project GUI through javascript. Important thing to note is that in the GUI indexed properties are being generated through javascript.

In short this is the object structure.

Project
------ worksheets(List of WorksheetDetail object)
------ parts(List of Parts objects)

So for PartName id is generated as project.worksheets[0].parts[0].name. Also project is present as a field in the form used for the page.

Now while submitting I am getting IndexOutOfBounds Exception when I submit the form. After doing some debugging I found that local server while executing getWorksheets() on Project object, empty List object is returned. Now here is the dilemma.

1) I read somewhere that this might happen when form is not found in request so at the time of submission server creates a new instance of form, with all fields initialized to default values. But do we always have to save the form object explicitly upon each request?? I don't remember having read such thing earlier (although makes sense to me). If yes, then is there any guideline on the name of the attribute to which this object should be bound ?? Is there an article, resource where I can read and understand about this concept.

2) Also Request1 is over with display of page. GUI is painted with request2, AJAX call so do I have to make sure form exists in request2 as well since this is the last request before which the page loaded.

I can give the code of the three java files but they are simple getters an setters. Also for List object fields indexed getters and setters have been defined. Any help is appreciated.


Kamal Tripathi
SCJP 1.4 90%, SCWCD5 94%, Next SCDJWS--> In Naescent stage. Researching abt exam and material itself.
Kamal Tripathi
Ranch Hand

Joined: Oct 02, 2008
Posts: 86
Just some more information that might help you help me

In one of the older posts. I found a resource on StrutsCatalogLazyList. With reference to this.

1) Does the bug still exist coz I use java 1.4? I clicked on the bug link but it says its an invalid bug no.
2) I would prefer not to redefine my List fields as arrays since getters and setters are used at lots of places.
3) The object still goes deeper and have list objects. But I am sure it is failing at worksheets level an once it is resolved remaining should be resolved too.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IndexOutOfBounds while submitting form.