struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurizio Cucchiara <>
Subject RE: How to structure a struts2 application
Date Mon, 27 Sep 2010 21:38:02 GMT
Hi Darren,

> However im not sure if this is the best way of doing things because all of
> the user actions would share the same validate method, and each different
> type of action would need different validation. I was thinking of maybe
> putting a switch in the validate method to do different validation depending
> on which action has been called, or perhaps just having different action
> classes for each type of user action.
> You don't need multiple classes. The validate interceptor, as the prepare
one, is very flexible in this sense. You can define multiple validate
methods inside a single action class. Particularly, you could define a
validate (prepare) method  for every entry point (for instance: update,
delete, etc.).  You must only follow the convention: use updateValidate for
validate method update, deleteValidate from delete entry point, and so on.
Remember that validate/prepare method is always invoked (so you can put here
common validation rule).
Furthermore, you can encapsulate validation logic inside an xml file, alway
following the conventions:

Maurizio Cucchiara

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message