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 nested:iterate with array within array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "nested:iterate with array within array" Watch "nested:iterate with array within array" New topic
Author

nested:iterate with array within array

sue curt
Greenhorn

Joined: Aug 13, 2012
Posts: 2
I am using Struts 1.3.8. I have a jsp with multiple included jsps. There are many input fields that are arrays and the user can click "addrow" and get an empty row for that field. All the "adds" with a single array work fine. I need an array of Paths that can each contain an array of segments. Adding a blank Path is working. But, I get the error of cannot find bean if I try to add a blank segment row. The code format that I used was copied from an existing app that allows users to update fields, but not add a new row. I am really stumped. I have not been able to find an answer to this. Any help would be appreciated. Thanks.
Below is snippets of code for the jsps, struts-config, classes.

11:57:41,713 - Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspException: Cannot find bean: "pathDetailId[0].segmentDetailId" in any scope
at org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:864)
at org.apache.struts.taglib.html.CheckboxTag.isChecked(CheckboxTag.java:151)
at org.apache.struts.taglib.html.CheckboxTag.doStartTag(CheckboxTag.java:124)
at org.apache.struts.taglib.nested.html.NestedCheckboxTag.doStartTag(NestedCheckboxTag.java:63)
at org.apache.jsp.dataPath_jsp._jspx_meth_nested_005fcheckbox_005f1(dataPath_jsp.java:822)
at org.apache.jsp.dataPath_jsp._jspService(dataPath_jsp.java:342)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)

JSP with multiple included jsps


jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

Hi Sue,

Please use the code tag ..
Regards
Jatan
sue curt
Greenhorn

Joined: Aug 13, 2012
Posts: 2
I have this working now. I removed the name= from the inside iterate nested:text. I let struts determine the name. When I view the source, I can see that the name is path[0]segment[0].bandwidth, etc. So, I don't get the "can't find bean error". But, then I got index out of bounds on the beanUtil.populate getIndexedProperty. This occurs because it can't find the pathArray when returning from the action class after adding a blank segment row. I changed the scope in the struts-config to be session instead of request. It is correctly writting to the database and returns to the jsp with the correct data.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: nested:iterate with array within array