struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Affan Qureshi" <quere...@etilize.com>
Subject Re: Pre-populating DynaActionForm Bean (solved)
Date Sat, 21 Dec 2002 13:12:26 GMT
Should use the following way to instantiate a DynaActionForm:

DynaBean form =
DynaActionFormClass.getDynaActionFormClass("accessory").newInstance();

But surprisingly i can't find this method on the API on the Docs on the
struts website. http://jakarta.apache.org/struts/api/index.html

Thanks,

Affan

----- Original Message -----
From: "Affan Qureshi" <quereshi@etilize.com>
To: "Struts Users Mailing List" <struts-user@jakarta.apache.org>
Sent: Saturday, December 21, 2002 4:33 PM
Subject: Re: Pre-populating DynaActionForm Bean


> I have a similar scenario but in my case the sending action does not have
> the same form bean bean associated as the destination. So what I want to
do
> is to instantiate a form bean which the JSP is expecting and put it in the
> request scope.
>
> Here is my code:
>
> DynaActionForm form = new DynaActionForm();
> form.set("productId", String.valueOf(acc.getProductId()));
> form.set("mfrPartNumber", acc.getAccessoryProduct().getMfgPartNo());
> form.set("description", acc.getAccessoryProduct().getDescription());
> form.set("notes", acc.getNotes());
> req.setAttribute("accessory", form);
>
> This is the JSP to which I am sending this request:
> <html:form action="saveAcc.do" method="GET" >
>             <html:text property="productId"
size="25"readonly="true"/></td>
>             <html:text property="mfrPartNumber" size="25"/></td>
>             <html:text property="description" size="25"/></td>
>             <html:textarea property="notes" rows="8"/></td>
>             <html:submit >Save Accessory</html:submit>
>     </html:form>
>
> In struts-config.xml I have the following def for action saveAcc.do
> <action path="/saveAcc" type="my.mypackage.MySaveAccessoryAction"
> name="accessory" validate="false" scope="request">
>
> This is the error I get when submitting to the JSP:
> java.lang.NullPointerException at
>
org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:
> 545) at
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:361)
> at com.etilize.cms.web.actions.AddAccessoriesAction.editAccessory ......
> (more...)
>
> I am sorry if this has come up earlier but I could not find one.
>
> Thanks a lot.
> Affan



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message