Thanks Haritha, I think something along the lines you described would be the 
way to go, although I like the default look and feel of invalid controls (red 
border, tooltip with error etc.) I guess I would need to develop my own 
"validation framework" which I currently don't have time to, unfortunately.

If this reads someone from Adobe, please take a look at Silverlight 3 + .NET 
RIA Services and how they approach validation - they do it right. Flex, out of 
the box, supports only validation in the View layer which is architecturally 
wrong.

--- In flexcoders@yahoogroups.com, "flexcoder99" <haritha.moos...@...> wrote:
>
> 
> We had similar issue in our application. 
> 
> We had two different ways of adding data....in the grid or in a form view. So 
> one model - two views.
> With Validation being coupled tightly with View, validation logic would be in 
> two places -  
> Grid column level AND 
> FormItem level
> 
> To avoid this we did validation on the Model (actually in a VO which resides 
> in a Model). Here is how we did it.
> 
> In the constructor of VO, initialized ALL validators and added them to an 
> Array. 
> Made the data members 'private' and addded public setter/getters.
> Added errorString member variable to VO.
> In the setter method validated the data using a specific validator or in some 
> cases called validateAll.
> Set/append the error message to errorString...(if multiple fields have 
> erroneous data then error messages are appended)
> 
> To show validation error in the view:
> Grid - Added a column to the left that would show an icon in case errorString 
> was not empty. The icon shows errorString as Tooltip
> Form -  On top of the form Showing/Hiding the same error icon used in the 
> grid. With a toolTip that show actual error message
> 
> -Haritha
> 
> --- In flexcoders@yahoogroups.com, Richard Rodseth <rrodseth@> wrote:
> >
> > Whether or not the validation is done in the view or presentation model,
> > note that the framework classes like NumberValidator can be instantiated and
> > invoked in ActionScript.
> > 
> > On Tue, Apr 14, 2009 at 9:49 AM, claudiu ursica <the_braniak@>wrote:
> > 
> > >
> > >
> > > Now the validation is triggered by the view but you can forward the actual
> > > validation to the presentationModel instance who actually does the
> > > validation ... so the view only display the info that comes from the model
> > > and that's it...
> > >
> > > C
> > > ------------------------------
> > > *From:* Borek <borekbe@>
> > > *To:* flexcoders@yahoogroups.com
> > > *Sent:* Tuesday, April 14, 2009 7:25:47 PM
> > > *Subject:* [flexcoders] Re: Validation in Model (rather than in View)
> > >
> > >  How does the Presentation Model pattern help?
> > >
> > > --- In flexcod...@yahoogro ups.com <flexcoders%40yahoogroups.com>, claudiu
> > > ursica <the_braniak@ ...> wrote:
> > > >
> > > > Have a look a the presentaion model pattern maybe helps your cause...
> > > >
> > > > C
> > > >
> > > >
> > > >
> > > >
> > > > ____________ _________ _________ __
> > > > From: Borek <borekbe@ >
> > > > To: flexcod...@yahoogro ups.com <flexcoders%40yahoogroups.com>
> > > > Sent: Tuesday, April 14, 2009 6:16:56 PM
> > > > Subject: [flexcoders] Validation in Model (rather than in View)
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Flex supports validation in the View layer quite well but the problem is
> > > that the validation rules should not be there at all. They belong to Model
> > > but I'm not sure how to implement that in Flex.
> > > >
> > > > I would like to be able to do something like this:
> > > >
> > > > [Required]
> > > > [String(minLength= "5")]
> > > > public var name : String;
> > > >
> > > > and then just have the TextInput in the View validated automatically.
> > > Silverlight + .NET RIA Services can work like that but is that possible in
> > > Flex where we don't have 2-way data binding?
> > > >
> > > > Thanks,
> > > > Borek
> > > >
> > >
> > >
> > >  
> > >
> >
>


Reply via email to