I am working on a CRUD application.  When a user prepares to update a
record, I have to confirm his choice before making the update.  Therefore,
to add a new record, the states are like this:

        1.  Show a blank form to get the user input
        2.  Validate the form and ask "Are you sure you want to add this record?"
        3.  Update the record in the database

The user can back up from step 2 to step 1 and correct a mistake if he sees
one.  This is done by checking for a "back" parameter in the ActionClass for
step 3 and forwarding to the "back" mapping if it exists.

I can quite naturally get the input that I need in step 1, since this uses
an HTML form.  However, the page for step 2 doesn't have a form at all (i.e.
it's just a regular page with no <html:form>).  Therefore, when I reach step
3, the form bean's properties are null, even though they were populated at
step 2. 

Of course, I could work around by putting a form on the page for step 2 and
using hidden fields for every property, but this seems inelegant.  I would
like to keep the form bean as an object at this point.  It's a pain to
unroll it into a bunch of strings that can be used to poulate the hidden
field -- only to have to convert them back to native types (like
java.util.Date) again so they can be passed to the database classes.

It seems to me that there are two ways to solve this:

        1.  Use session scope, since the bean will be maintained until the final
step when it is cleared from the session.  Using session scope is bad for
scalability and failover, but it does solve my problem.

        2.  Find some way to pass (in request scope) the form bean from step 1,
through to step 2, then to step 3.

Is there any easy or reliable way to do this?

Another (sort of related) question:

After the record is updated in step 3, I want to show a status message on
the main page.  I am using ActionMessages to do this.  I am adding the
status message in request scope and just doing a forward to the main page --
and it's working.  However, if I change the struts-config.xml to set
redirect="true" instead of just forwarding (so the user can refresh the page
without submitting the form again) then the ActionMessage gets lost.  Does a
redirect transcend request scope?  Any way to work around this?

Thanks!

Tom

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to