ModelState really just allows you to ask questions like "is everything
valid" and to iterate across the state of "action" as a whole looking for
errors which may have occured - basically it's a big dictionary... so in
your controller you can check to see if everythings ok..

if (ModelState.IsValid) { .... }

Or you could add an error for a certain parameter...

ModelState.AddModelError("customer.Address.Street", "Street is a required
value");

ModelState is a property of the controller, of type "ModelStateDictionary"
... and it really is just a dictionary of strings to instances of
"ModelState"...  ModelState stores a list of exceptions/errors
(ModelErrorCollection) and the Value (ValueProviderResult).

ValueProviderResult provides access to the raw value returned from the
binder, as well as what culture was used to create the raw value.

It's not really all that different to monorail - they just invert it so that
state is associated with the key, rather then having seperate validation
summaries per object - you could probably a tailor a wrapper over the top of
monorails current implementation to emulate the model state behavior to a
degree.

I've only done one ASP.Net MVC project so far as well, but I'm not sure they
had an equivalent to monorails simple errors collection available for
managing errors not associated with the current form that you would like to
display in a validation summary.. but I could be wrong, I never needed that
feature at the time.

http://msdn.microsoft.com/en-us/library/system.web.mvc.modelstatedictionary_members.aspx
http://msdn.microsoft.com/en-us/library/system.web.mvc.modelstate_members.aspx
http://msdn.microsoft.com/en-us/library/system.web.mvc.modelerrorcollection_members.aspx
http://msdn.microsoft.com/en-us/library/system.web.mvc.modelerror_members.aspx
http://msdn.microsoft.com/en-us/library/system.web.mvc.valueproviderresult_members.aspx

Cheers,

 - Alex

On Wed, Apr 1, 2009 at 1:23 AM, Rafael Teixeira <[email protected]> wrote:

> No, it is the pattern I've been using for decades of having the various
> validators collect together their complaints about the input, so that they
> can be rendered at once in the view.
> Monorail also can do that, but the good thing is that the ModelState can be
> further manipulated in a easy way before being handed out to the view
> engine, which I think is just a bit more difficult in Monorail, but maybe
> it's just my ignorance on the subject.
>
> Cheers,
>
> On Tue, Mar 31, 2009 at 8:18 AM, Markus Zywitza 
> <[email protected]>wrote:
>
>> Is this ViewState for MVC?
>>
>> 2009/3/30 c.sokun <[email protected]>
>>
>>
>>> Have anyone look into ASP.NET <http://asp.net/> MVC ModelState feature?
>>>
>>>
>>>
>
>
> --
> Rafael "Monoman" Teixeira
> ---------------------------------------
> "I myself am made entirely of flaws, stitched together with good
> intentions."
> Augusten Burroughs
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Development List" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to