Hi, I'm fairly new to struts and I'm having a puzzling problem. Let me start with some quick background: I'm attempting to make a highly configurable and extensible web interface for a statistical analysis engine. Because of the large (and arbitrary) number of types of analyses, I opted not to create a seperate bean and JSP form for each type. Most of these analyses extend other analyses, so I have made a JSP for each one that uses an include directive to bring in the form elements from the base class(es) to prevent duplicating that code for all the children. This also entails not having a specific bean class for each analysis type, so I'm using a LazyDynaBean. Keep in mind that I use beans that I actually define as my own classes in other places in this webapp and it works fine, but I don't use LazyDynaBeans (or any kind of DynaBean) anywhere else.
I've been assured by many websites that I can specify in my struts-config.xml a form-bean of type org.apache.commons.beanutils.LazyDynaBean and it will somehow be wrapped in some kind of ActionForm automatically. In an attempt to figure out what kind of ActionForm subclass this was, I decided to put a System.out in one of my execute() methods in the strut to tell me via form.getClass().getName(). To my surprise, I got a null pointer exception, and after a little more investigation, I found out form was null. This is way over my head - like I said, I'm new to struts. Below, I have what I believe are relevant excerpts of code and config files... from struts-config.xml: <form-bean name="AnalysisForm" type="org.apache.commons.beanutils.LazyDynaBean"> <form-property name="runnableTables" type="java.lang.Integer" initial="1" /> <form-property name="runnableTableTypes" type="java.lang.String[]" /> <form-property name="runnableTableNames" type="java.lang.String[]" /> <form-property name="outputIntermediaryValues" type="java.lang.Boolean" /> <form-property name="filtered" type="java.lang.Boolean" /> <form-property name="notifyValues" type="java.lang.Float[]" /> <form-property name="notifyComparisons" type="java.lang.String[]" /> <form-property name="notifyResults" type="java.lang.String[]" /> </form-bean> ... snip... <action path="/AnalysisConfig" name="AnalysisForm" type="org.assistment.apps.newReporting.analysis.struts.AnalysisConfig" scope="request" parameter="method"> <forward name="Sum" path="/pages/stats/SumAnalysis.jsp" redirect="false"/> <forward name="Count" path="/pages/stats/CountAnalysis.jsp" redirect="false"/> <forward name="Average" path="/pages/stats/AverageAnalysis.jsp" redirect="false"/> <forward name="Variance" path="/pages/stats/VarianceAnalysis.jsp" redirect="false"/> <forward name="TTest" path="/pages/stats/TTestAnalysis.jsp" redirect="false"/> </action> here's an example of one of the forwards' targets, SumAnalysis.jsp. The header includes the appropriate taglibs, and the includes in the table body contain only <TR>...form stuff...</TR>. Note that some of them have .html extensions because tomcat seems to have an issue where it attempts to compile included JSP's before actually including them (took me hours to debug that). <jsp:useBean id="AnalysisForm" scope="request" class="org.apache.commons.beanutils.LazyDynaBean"/> <%@ include file="StatsHeader.html" %> <html:form action="/AnalysisConfig.do"> <input type="hidden" name="method" value="save"> <input type="hidden" name="type" value="Sum"> <TABLE WIDTH="85%"> <%@ include file="StatisticalAnalysis.html" %> <%@ include file="FilteredAnalysis.html" %> <TR> <TD>Sum Field</TD> <TD> Select the field of the result tables to perform the summation on:<BR> <html:select property="sumField"> <html:options name="fieldList"/> </html:select> </TD> </TR> <%@ include file="Notification.html" %> <TR> <TD> <html:submit>Save</html:submit> </TD> </TR> </TABLE> </html:form> <%@ include file="StatsFooter.jsp" %> Here's the relevant function from my AnalysisConfig.java strut class (which extends DispatchAction, hence the method name being "save" instead of "execute"): public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { Experiment exp = (Experiment)request.getSession().getAttribute("Experiment"); if (exp == null) { request.setAttribute("errorMessage", "Unable to get Experiment out of the session attributes."); return mapping.findForward("ExperimentManagerError"); } if (form == null) System.out.println("form is null!"); else System.out.println(form.getClass().getName()); // TODO: I'm creating a CountAnalysis for testing, make this more intelligent later StatisticalAnalysis analysis = new CountAnalysis(); // TODO: configure analysis here exp.addAnalysis(analysis); return mapping.findForward("AnalysisConfigReturn"); } I hope you'll forgive the long post... I just wanted to provide enough information for someone to spot my error. I'd greatly appreciate any help you can give. Thank you very much for reading this far! Ryan (aka Yanroy) -- View this message in context: http://www.nabble.com/ActionForm-is-null-when-using-dynabean-tf1908060.html#a5222710 Sent from the Struts - User forum at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]