CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • How check business rules and update the error list when an Item is added to a collection

    rated by 0 users
    Answered (Verified) This post has 1 verified answer | 4 Replies | 2 Followers

    Not Ranked
    8 Posts
    olawal posted on Mon, Dec 5 2011 3:34 PM

    Does anyone have any code sampels that do not rely on  OnPropertyChanged  for checking the business rules and passing errors back the the UI (2 tier application)

    right now the code uses a handler and activates a callback action to acomplish this but it only works sporadically.  ie :

    Protected Overrides Sub OnCollectionChanged(e As System.Collections.Specialized.NotifyCollectionChangedEventArgs)
    
    thanks in advance
    
    
    -ola

    Answered (Verified) Verified Answer

    Top 10 Contributor
    9,475 Posts
    Verified by olawal

    I discuss this in the Using CSLA 4 ebook series.

    The short answer is that in the parent object you override OnChildChanged, and that way you know that a child object has changed so you can execute appropriate rules in the parent object by calling BusinessRules.CheckRules.

    I don't know how this will work with ajax callbacks. If the state available on the web/app server isn't current, clearly you can't run any rules at that location. So you'll have to implement your solution such that the web/app server has the current state at the point you expect the rules to run.

    Rocky

    All Replies

    Top 10 Contributor
    9,475 Posts

    Do you want the validation error to appear as part of the parent object that contains the collection, or the child object(s) in the collection?

    Either way, you should consider overriding OnChildChanged in the parent object that contains the collection, and that's where you should either trigger the rules in the parent, or trigger the rules in the child that was changed.

    Rocky

    Not Ranked
    8 Posts

    I never got an email to know that you had answered thsi question along with the fact that I got pulled into another project and funally just got back to working on this problem.

    You are correct in that I do want the error to to be part of the parent object that contains the collection.  I don't know if this will work though since there are no postbacks with the way the code we have is wirtten  its  constits of alot of jquery and ajax elements.

    thanks again

     

     

    Top 10 Contributor
    9,475 Posts
    Verified by olawal

    I discuss this in the Using CSLA 4 ebook series.

    The short answer is that in the parent object you override OnChildChanged, and that way you know that a child object has changed so you can execute appropriate rules in the parent object by calling BusinessRules.CheckRules.

    I don't know how this will work with ajax callbacks. If the state available on the web/app server isn't current, clearly you can't run any rules at that location. So you'll have to implement your solution such that the web/app server has the current state at the point you expect the rules to run.

    Rocky

    Not Ranked
    8 Posts
    olawal replied on Tue, Jan 10 2012 12:11 PM

    Ok you basically confirmed what I thought

    We found a work arround using SQL to create a specific error message , I then catch that error and display the specific error  based on the content in the message.  A bit ugly but it works well in this scenario.  The only thing I dislike is I could not grab error message constants from my business rule withoute fully instantiaing it Argh!

    thanks for the fast feedback

    -ola

    Page 1 of 1 (5 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems