If you want to use a session bean that accumulates the values across all the
pages, you can do that.
When pages 4 and 5 are submitted, the file upload will be written to disk as
the form bean is being populated, which is before your form bean's
validate() method is called. From that perspective, you do not need to worry
about the uploaded data being kept around in the session - it will already
be on disk.
The one thing to be aware of is that your Action will need to "remember" the
uploaded data from page 4. By this I mean that your Action should look at
the FormFile object and either move or copy the file that was created with
the data for page 4. This is because, when page 5 is processed, a new
multipart handler may be created and the old one released. When the old
handler is released, it will delete any files it created, so if you don't
take steps to save the file you uploaded on page 4, it will be deleted when
you submit page 5.
> Should I bother setting the "name" value in the bean for the form input
> of the file? Do I need to do any validation for the file item?
I'm not sure what you mean by 'setting the "name" value in the bean'. In the
<html:file> tag, you don't need to specify 'name', but you do need to
specify 'property'. That's how Struts figures out which form bean attribute
to set when the file is uploaded. Regarding validation, you might want to
validate that a file was indeed uploaded, if it is required.
Hope this helps.
--
Martin Cooper
----- Original Message -----
From: "Jonathan Asbell" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 10, 2001 9:11 PM
Subject: Mixing a multipart form with beans
If I have a 5 page "wizard" (five consecutive form pages) and one bean,
where the first three forms are regular requests and the fourth and
fifth are each multipart forms, how do I use a bean with these pages?
Do I:
1) fill bean with the form values from page 1,2 and 3 ?
2) then for the multipart forms on the last 2 pages fill the bean with
the regular String values while simultaneuosly writing the file to disk
but dont submit the bean filled with values until the last page?
Should I bother setting the "name" value in the bean for the form input
of the file? Do I need to do any validation for the file item?
The way I see it is that there are request values that I need to get
from the request which are NOT binaries, and I need include them in the
bean. However, I am guessing that I should write the file as soon as
possible to disk and NOT store it in session. The question remains as
to exactly when I am submitting the bean and its values. At the same
time that I am writing the file to disk? Eariler? Later?