tags:

views:

24

answers:

1

Here is the situation.

I have 3 actions 1. action/create_something 2. action/save_something 3. action/preview_something

I start at www.site.com/action/create_something

I fill in some info and submit a form which passes to the save_something action

save_something creates an object foo based on the form inputs. foo now has a field call id ("123"). It then saves some data relevant from foo into the database and forwards to preview_something with the id parameter.

Now I am at www.site.com/action/preview_something?id=123

I take the id and create foo by hitting the database. On the page I display the various fields in foo.

Ok... my question is this:

Is it necessary to pass id to action/preview_something and hit the database again? Is foo still available to me? Does my object foo still exist in the scope of my action class?

Sorry for the newbishness going on here.

A: 

Ok, parameter is not available anymore in preview with your case.

Possible solution #1:

Your struts Action can implement ServletRequestAware. Then you can save your foo object to session in save() method and then read it in preview().

Possible solution #2:

In your save() you can just return preview() and whole scope (object foo, parameters,...) will stay the same as in save().

This would be the easiest way to do it.

Trick