-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tarek,

Tarek Nabil wrote:
> One of the problems with Struts was that if you had a page that requires
> some setup and this page submits to an Action, then you would not be
> able to set validate to true on that action because if validation
> problems occur then Struts will take you directly to the input JSP
> without performing the setup and your JSP wouldn't work.
> 
> A solution to that would be to specify the input of the action as the
> setup action, which means you're doing action chaining and Struts is not
> good at that (it will reset your form among other things).
> 
> The solution of choice for us so far was to call validate() ourselves in
> the action and if a validation problem occurs then we call the setup
> method (eventually you start using your action methods as an API which
> still was not good).

I totally disagree. If you have an action that you want to use like
this, you can always set up two different mappings -- one that /does/
validate and another that does /not/ validate.

My experience has been that Struts is very good at "action chaining"...
in fact, that's the major advantage of Struts in the first place: the
ability to map URIs to actions and specify their relationships through
forward mappings.

> Another problematic scenario is the case when you're editing some
> database record for example. When you go to your setup action for the
> first time, you will populate drop down lists for example, and then load
> the existing values from the database to your JSP fields. If the user
> attempts to save and some problem occurs then in the setup action, you
> will need to again populate the drop down lists, but you will NOT want
> to overwrite the user's inputs with the existing data. This is very
> similar to the first problem, but you would also need to pass some flag
> to the setup method to tell it whether to copy the data from the
> database to your ActionForm.

In this case, what you want is something like:

LoadAction -> EditAction -> Display form

Form submits to SaveAction, which has EditAction as input (not LoadAction).

This is pretty standard stuff, and works beautifully.

> Does Struts 2 or even WW 2.2.4 solve that problem in an elegant way?

I really hope so, since Struts 1.x also does.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFbYyx9CaO5/Lv0PARArpHAJ0U3fHybMWepSZxPjciDU3+6M2PwQCgoy8B
FRlfdQsyONpgqGvrHBuZuFw=
=EbD/
-----END PGP SIGNATURE-----

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

Reply via email to