I am having some problem using the nested struts. As I created enough mess
in my original code by trying out different options, here is a small project
that I setup just to test this thing out first. 
So, I have two form beans TestFirst and TestSecond. TestFirst extends
org.apache.struts.action.ActionForm and is the parent that contains a
collection of TestSecond.
TestFirst.java
        public ArrayList getPages() { return _pageList; }

        public Object[] getPageList () { return _pageList.toArray(); }
        public void setPageList (Object[] pList)
        {
                _pageList = new ArrayList((Arrays.asList(pList)));
        }
test.jsp
        <html:form action="/setTestList">
                <nested:hidden property="method" value="setTestList"/>
                <jsp:useBean id="testBean"
type="com.webmd.qaadmin.forms.TestFirst" scope="session"/>
                <table>
                        <nested:root name="testBean">
                        <tr>
                                <td><nested:text property="questionnaireId"
/></td>
                                <td><nested:text
property="questionnaireName" /></td>
                        </tr>   
                                <nested:iterate property="pageList"
type="com.webmd.qaadmin.forms.TestSecond" indexId="inId">       
                                <tr>
                                <td></td>
                                        <td><nested:text property="pageId"
/></td>
                                        <td><nested:text
property="pageTitle" /></td>
                                </tr>
                                </nested:iterate>
                        </nested:root>
                </table>
                <html:submit >Save</html:submit>
        </html:form>
Struts_config.xml
                <struts-config>
                  <form-beans>    
                    <form-bean  name="testBean"
        
type="com.webmd.qaadmin.forms.TestFirst"/>                       
                  </form-beans>  
                   <action-mappings>
                    <action  path="/getTestList"
                        type="com.webmd.qaadmin.action.TestAction"
                        name="testBean"
                        scope="session"
                        parameter="method"   
                        validate="false">
                        <forward name="display" path="/test.jsp" />     
                        <forward name="error" path="/test.jsp" />
                    </action>   
                    <action  path="/setTestList"
                        type="com.webmd.qaadmin.action.TestAction"
                        name="testBean"
                        scope="session"
                        parameter="method"  
                        input="/test.jsp"
                        validate="false">
                        <forward name="display" path="/test.jsp" />     
                        <forward name="error" path="/test.jsp" />
                    </action>       
                  </action-mappings>
                </struts-config>

In the Action I simple fill the form up in the getTestList() method and try
to get the use data in the setTestList() method.
Test.Jsp has just <nested:iterate> tag to iterate over the collection.
Now, getTestList() works fine and shows the data correctly in the jsp. but
when I submit this page the data(collection data of pagelist) doesnot go to
the action.
I get a ArrayIndexOutOfBoundsException. After debugging a little I found
that this exception is thrown in getPageList() method of TestFirst. When it
tries to do return _pageList.toArray(); as _pageList is null

Can you tell me what I might be missing. I have struts1.1 jar in my lib
folder and all the latest taglibs in web-inf
I have tried putting this in both session and request scope.

I would really appreciate your help.

Thanks  a lot ,
Sonali


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to