Re: Problem with webobject attributes in WOBuilder
Re: Problem with webobject attributes in WOBuilder
- Subject: Re: Problem with webobject attributes in WOBuilder
- From: Guido Neitzer <email@hidden>
- Date: Mon, 19 Jun 2006 15:29:21 +0200
On 19.06.2006, at 13:43 Uhr, John Stewart wrote:
Misunderstanding. My fault. I don't do validation in the controller.
I do validation in the model. But I catch the validation errors in an
"EditPage" class and inherit from this class to build my concrete
edit pages.
What do you define by validation? If it's simply 'shape' of data,
then of course that can exist in the Model. But surely the
'significance' of the data can depend on Controller state, hence
should be validated at Controller level?
"Validation" as it is used by the WebObject documentation is the
process of making sure that one EO for itself is valid, say, all its
attributes are in a state that the object itself thinks, it can be
stored in the database.
You can do some "high level" things in the model layer (ensuring the
integrity of a complete shopping cart) but the collecting of thrown
exceptions from the validation is what the controller should do. The
model itself just says "No, I can't do this, because ...". Reacting
to this messages is part of the controller. Displaying the errors is
work of a view. Connecting the thrown error messages and the view is
work for the controller.
So, in practice all layers work together in the process of validating
user input: the model layer ensures the integrity of the objects that
should be stored somewhere, the controller collects information about
(un-) successful validation in the model and one or more views brings
this information back to the user.
So, when you understand "validation" in the way it is often meant in
the docs, then it belongs in the model layer. If you understand (as I
do) "validation" as the process of ensuring that a user has entered
valid data and if not showing this information to him, then
validation belongs to all layers.
cug
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden