On 6/20/05, Janek Ziniewicz <[EMAIL PROTECTED]> wrote:
> I probably have found an error. It needs short description.
> Each of ActionForms in my app uses two Action classes. One is
> 'typical' form launched after  submitting a form. Its execute method
> forwards to next Action which sets data for new form before displaying
> it.
> [..] --> PreAction1 --> ActionForm1 --> Action1 --> PreAction2 -->
> ActionForm2 --> [...]

You server cannot receive mulitple POST requests unless you do
redirect with 307 response code, which is hugely unlikely.

How do you know that you receive two POST requests? Your logs are on
the server, they are invoked after HTTP request is processed, and Java
request object is created and delivered to an action. Most likely, you
receive the same Java request object because Struts processes the new
action again. I doubt that you actually receive HTTP request. Did you
run HTTP sniffer?

By definition, more than two linked actions form a chain, and chains
are frowned upon. Do you really need to have more than two actions?
You might want to read this, for example:
http://wiki.apache.org/struts/StrutsCatalogInputOutputSeparation
You need to realise that Struts repeats the whole
reset/populate/validate sequence when you forward the request to
another action mapping.

> Now, I guess that all actions generate GETs/POSTs. My logs prove it.

No, at best, actions generate responses. Requests are generated by
browser. Struts repeats reset/populate/validate sequence when you
forward to another action mapping, this may fool you into thinking
that actions generate requests. They do not.

> Submiting a form proceeds without an error if its method=="GET". With
> POST I still get it. Everything would be fine if I could use only GET
> method.

This is not proper way to submit forms, but of course you can deviate
from the standard if you have reasons to do it.

> My question is, how can i get rid of this 'multi submit' error? I use
> PreActions mainly for prepopulating data in new form. Maybe there is
> some other nice way to do it?

1. If you do redirect on second action mapping instead of forwarding,
then request will be "clean", and Struts will not try to populate
form's fields. On the other hand, all your request-scope data will be
lost. I prefer this choice, even if it is more laborious. But I get
completely detached input and output phases.

2. You can do forwarding, but then you need to use different form and
setters with different names.

3. Even better, use different form and no setters at all. Struts is
honest and uses getters/setters to access your form properties.

Michael.

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

Reply via email to