This is a Struts 2 question.
I'm looking for a common solution to the problem stated in the subject.
The easiest way to explain what exactly I want is with an example.
I have two actions:
1) ListAction, that displays a list of database entries.
2) CreateAction, that receives input from a form, creates a new entry in
the database and passes control to the ListAction.
The last thing to say about the ListAction is that it should be able to
display messages like "entry successfully created" if it is executed
after CreateAction (as described above).
Following things are important for me:
1) Both actions must run within the same HTTP request from browser.
(don't really care how many HttpRequest instances are created.)
2) The ListAction should NOT receive any of the parameters, received by
CreateAction. (a new clean HttpRequest for ListAction would be actually
ideal)
Please don't tell me something like "if the action properties of both
action classes don't match, the parameters won't be transferred anyway"
or "use another method instead of execute". _I want to avoid any effort
of ensuring that no accidental parameter interference between the two
actions occurs_.
3) it should be able to specify explicitely (via struts.xml or within
the execute() of CreateAction) which parameters I want to pass to
ListAction.
4) I DON'T want to pass parameters through session.
I have tried following things, neither of which satisfies me:
1) for CreateAction use result type="redirect-action" and use dynamic
parameters in struts.xml.
Don't like this approach because there are two requests from browser and
the parameters are passed through an URI of the second request. Thus I'm
unable to easily pass anything more complicated than a string and
finally I don't want to dispose any internal stuff through URLs visible
in the browser.
2) use result type="chain"
As far as I can see this thing is designed to allow two actions to
process the same HttpRequest (If I'm wrong or missing something a
comment is appreciated)
Which is again NOT what I want. If the ListAction accidentally
recognizes some parameters recognized by CreateAction, I will have a
problem.
Further using this approach I have tried to clear() the request Map
(obtained through RequestAware) but when this is done, the JSP of
ListAction won't display any ListAction properties. Obviously clear()
breaks some essentials. (it kills the valuestack object in the request
map as far as I have seen while debugging, which for some obscure reason
prevents the final JSP to obtain any of the properties of ListAction).
Thus my question is:
What's the right way of forwarding to another action, having a clean
request for this another action but being able to pass some parameters
from the initial action.
This is a simple requirement, that is needed in almost any webapp I can
imagine, and I absolutely believe something like this must be a core
feature.
But I simply don't see a solution after spending several days on it!
Any ideas or comments heavily appreciated!
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]