--- "Craig R. McClanahan" <[EMAIL PROTECTED]> wrote: > > > On Mon, 22 Jul 2002, Matt Raible wrote: > > > Date: Mon, 22 Jul 2002 18:40:56 -0600 > > From: Matt Raible <[EMAIL PROTECTED]> > > Reply-To: Struts Developers List <[EMAIL PROTECTED]> > > To: [EMAIL PROTECTED] > > Subject: NPE when setting values on DynaActionForm > > > > I want to populate a DynaActionForm before dispatching to a JSP, however > > the following doesn't work: > > > > DynaActionForm requestForm = new DynaActionForm(); > > requestForm.set("subject", subject); > > requestForm.set("content", content); > > requestForm.set("courseId", cForm.getCourseId()); > > requestForm.set("courseName", cForm.getName()); > > > > I get a NPE at the first .set - here is my configuration: > > > > This won't work because the DynaActionForm you created doesn't know what > the set of valid properties are. > > > <form-bean name="requestForm" > > type="org.apache.struts.action.DynaActionForm"> > > <form-property name="action" type="java.lang.String"/> > > <form-property name="courseId" type="java.lang.String"/> > > <form-property name="courseName" type="java.lang.String"/> > > <form-property name="type" type="java.lang.String"/> > > <form-property name="subject" type="java.lang.String"/> > > <form-property name="content" type="java.lang.String"/> > > <form-property name="message" type="java.lang.String"/> > > </form-bean> > > > > Should it? > > > > With the current APIs, it is surprisingly hard to do this, because there > is no convenient way to get to the underlying DynaActionFormClass > instance. I"m going to be adding some API in tonight's nightly build so > that you will be able to say: > > DynaActionForm requestForm = > DynaActionFormClass.getDynaClass("requestForm").newInstance(); >
I'd much rather do the above ^ than the below. I'll look for a commit that resembles this and download the nightly tomorrow. Will it just be in BeanUtils? I'd be willing to make the jump to 1.1 nightly if Tiles has been safely integrated and there's a plugin example. Last time I updated was a few weeks ago. > to get a DynaActionForm initalized with the correct properties. In the > mean time, a workaround is to declare that your "setup" action also uses > this form bean (so that Struts will set it up for you), or go through the > following exercise: > > ApplicationConfig appConfig = (ApplicationConfig) > request.getAttribute(Action.APPLICATION_KEY); > FormBeanConfig fbConfig = appConfig.findFormBeanConfig("requestForm"); > DynaActionForm requestForm = > DynaActionFormClass.createDynaActionFormClass(fbConfig).newInstance(); > > > Thanks, > > > > Matt > > > > Craig > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > Thanks, Matt __________________________________________________ Do You Yahoo!? Yahoo! Health - Feel better, live better http://health.yahoo.com -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>