You need to use the form which is passed in from the execute()
method signature.  

DynaForm dForm = (DynaForm) form;
dForm.set("author", "test");
return mapping.findForward("success");

This assumes you are using the same form for your setup and processing
action and you are forwarding to the page which renders the form.

robert

> -----Original Message-----
> From: Alexander Czernay [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, November 17, 2004 6:22 AM
> To: Struts Users Mailing List
> Subject: Prepopulate a DynaForm
> 
> 
> I'm trying to prepopulate a DynaForm with some values - right now just 
> hard-coded, later should be taken from a DB. For that I'm using a 
> SetupAction, that is called to prepopulate the form, insert it into the 
> request and after that forward to the actual action for presenting the 
> form to the user.
> 
> Looks like this:
> 
> public class MediaArchiveSetupAction extends Action {
>       public ActionForward execute(ActionMapping mapping,
>             ActionForm form,
>             HttpServletRequest request,
>             HttpServletResponse response){
>          
>           ActionServlet servlet = this.getServlet();
>           MediaArchiveForm mediaArchiveForm = new MediaArchiveForm();
>           mediaArchiveForm.setServlet(this.getServlet());
> 
>           MessageResources messageResources = servlet.getInternal();
> 
>           mediaArchiveForm.set("author", "test");
> 
>          
>         // TODO: check why this doesn't work
>         request.setAttribute("mediaArchiveForm", mediaArchiveForm);
>         // this does actually work
>         request.setAttribute("test", "dummy");
> 
>           return (mapping.findForward("success"));
>       }
> }
> 
> Using this approach I always get a null pointer exception, leading me to 
> the presumption that the actual form-object isn't built.
> 
> Any ideas why?
> 
> Thanks for any help,
> Alexander
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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

Reply via email to