Hmm, not a lot of comments on this. I guess there is a consensus on the matter (that, or no-one really gives a damn).

A quick followup on this; how could I achieve both

a) decoupling of my business classes from Struts
b) internationalization

if I validate in my business class?

1)
if (alreadyExists(email)) {
  throw new MyAppException("E-mail address already exists");

achieves a) but not b), and

2)
if (alreadyExists(email)) {
  throw new MyAppException("errors.email.duplicate");

achieves b) but not a)


From: "Robert Taylor" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Subject: RE: Proper place for validation
Date: Tue, 7 Sep 2004 08:21:09 -0400



From: "Robert Taylor" <[EMAIL PROTECTED]>
Reply-To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Subject: RE: Proper place for validation
Date: Tue, 7 Sep 2004 08:21:09 -0400

I would avoid putting any business logic in the action
class. Place this type of logic in the business class as it
most likely is validation that is valid across all application
logic and not for just one use case.

robert

> -----Original Message-----
> From: Janne Mattila [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, September 07, 2004 8:15 AM
> To: [EMAIL PROTECTED]
> Subject: Proper place for validation
>
>
> I am wondering what would be the propert place for some validation code.
> Let's say I have a registration page where user inputs his/her information
> for a new user account. There's a field for e-mail address. On one level
> that information is validated on the ActionForm, for things such as
>
> - field is not left empty, if it is required
> - field is a valid e-mail address
>
> That much seems quite clear. But where should I put a check that ensures
> that same e-mail address is not already used by an existing account?
>
> On the other hand, I could put it in the registration action, because
> checking that is (kind of) user-input validation, and action is a natural
> place to do this.
>
> On the other hand, I could put it in my business class. The pros for this
> would be smaller and simpler action code, and reuse if same check is needed
> with different actions.
>
> Any suggestions? Intuitively, I think I would put that check in the Action,
> but I am happy to hear any arguments in favor or opposing that.
>
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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


_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail



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



Reply via email to