I have a simple Struts form. It has a few text fields and a file field. The
enctype is multipart/form-data on my form. I validate in the actionform's
validate method. If the text fields are empty, I return errors that they
are required. Along with the visible fields, I pass a few hidden fields that
are needed as request params when the form is processed and returned to the
JSP. The JSP needs these request params.
Everything works great when there are no validation errors as the request
params get returned by using the ActionRedirect class in the action. But if
there are errors returned, I lose the request params. (I am able to access
them in the actionform validate method or in the action).
How can I make sure the request params are passed
back upon validation error in multipart form? Is there any sort of workaround?
Action-mappings (slightly edited for obfuscation) below:
<action
path="/saveQuestion"
type="blahblahblah.QuestionAction"
parameter="save"
name="QuestionForm"
input="populateQuestion.do"
scope="request"
validate="true">
<set-property property="cancellable" value="true"/>
<forward name="success" path="viewSurvey.do" redirect="true"/>
</action>
<action
path="populateQuestion"
type="blahblahblah.QuestionAction"
parameter="populateRequest"
name="ItemForm"
scope="request">
<forward name="success" path=".editing.Question"/>
</action>
And my JSP form line:
<html:form styleId="QuestionForm" action="/saveQuestion" enctype="multipart/form-data" method="POST">