Hello,
The Struts way to initialize a form with values retrieved in an Action is to
populate an ActionForm with the values that were retrieved (e.g. by using
PropertyUtils:copyProperties()) in the Action (viewDocument.do) itself.
So not in the reset() method, as the main purpose of this method is to deal
with checkboxes.
Arjan Kok.
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 15, 2000 3:47 PM
> To: [EMAIL PROTECTED]
> Subject: form initialization
>
>
>
> Hi
>
> I've read through the mailing list, and I see that there are several
> different threads that seams to be related to the issue of how to
> initialize a form with values. I'm sorry, but I don't find answers to
> my problems in these threads.
>
> My problem :
> I have a .jsp page with about 10 <form:text>. The form is used to view
> attributes for a document. Now I'm working on implementing
> "view document
> attributes", which should bring up a form with the attributes
> for a document.
>
> Here is what I though would work :
> An Action viewdocument.do which takes as a request parameter the id of
> the document to view the attributes for. This Action
> successfully retrieves
> the attributevalues for the document. Then I store a Document
> object in
> the request (I've also tried storing it in the session), and
> then forward
> to the .jsp page with <form:text> and a corresponding
> ViewForm ActionForm.
>
> In the ActionForm I have the reset method(), and in this method I get
> the Document object stored in the request, and populate the
> form properties with the correct values. So when the Struts
> framework calls
> the get methods, the values I've retrieved in the
> viewdocument Action should show up.
>
> Why I think the solution doesn't work :
> In the struts-config.xml file I've added the viewdocument
> action to the
> action-mappings, and also associated the ViewForm class.
> But then the reset method is called before the perform of the Action..
>
> I've also tried without associating the Action with the
> ViewForm, but then
> the reset method is never called..
>
> My question :
> Since I seem to have run out of good ideas this week (We've
> made some good progress on an application using Struts this
> week), I need some help.
>
> How can I initialize a form with values retrieved in an Action ?
>
> You might ask why I want to use a Form to view document
> attributes. The point is that I also have to make a edit.jsp,
> which obviously needs to be a form, and I want to use the
> same mechanism for both.
>
> My environment :
> Tomcat 3.2.1, Struts 1.0 (build 05122000)
>
> Have a nice weekend !
>
> Regards
> Alf Hogemark
>