The part of my app I'm working on is a simple form submit, take the
struts-example/subscription for example.
My form is accessed by an editRequestTime.do?action=Create call in the
browser.
In the form I use the <html:select> and <html:option> tags to display
a selection box that is part of the form.
My problem is, what is the best place to create the ArrayList containing the
elements
for the option tag?
In the struts example it is hardcoded at the start of the JSP, with a
disclaimer that
it would normally be populated by the database (and I assume not in the
JSP).
So I figured I'll put it in my editRequestTimeAction code. Pass it on to the
JSP using
a request.setAttribute(). This works fine is the form is accessed through
the editRequestTime
call.
However, the form submits to a new action, saveRequest.do. Which means that
if there is
an error in the form, saveRequestAction will be executed, after which it
will forward to the form
again. The form however is not aware of the ArrayList since it's not created
in the saveRequestAction
but only in the editRequestTimeAction.
It doesn't seem to make sense to have to create the ArrayList in both the
editRequestTimeAction
AND in the saveRequestTimeAction. Should I put the creation code (or at
least a handle to it)
in the JSP?? That doesn't seem to help the seperation?
Martijn.