Sunday, January 20, 2002 06:26 AM
When you forward from one Action to another, the event
is treated like a new request, and everything happens
all over again. Including the part where the ActionServlet
autopopulates the form from the HTTP request.
If you reuse ActionForms between actions, you must
be able to switch the form into a "read-only" mode., so
that the properties are not overwritten or reset. This is
just a matter of putting a "setReadOnly()" property
on the form, and then having the other setters check
this before passing a value along to its private variable.
Then, just be sure that your reset method goes through
each property's setter method, rather than accessing the
private variable directly. This way calling reset will not
clear the properties if getReadOnly()==true.
Your actions can then call setReadOnly(true) or (false) as
they pass the ActionForm along. The ActionServlet does
check to see if there is already an ActionForm before
creating another, so with the readonly property, this is
a very good way to get Actions to work together.
In the nightly build, there is also a new technique for calling
one Action class form another, to eliminate the baton passing.
But that would be another question :)