OK. I can only offer our experience, I'm afraid - so I don't know how
relevant it is.
For business rules (i.e. is the input valid for our business? - e.g. a
student number must be 8 digits, etc), we construct a remote validation
class that lives on the application server. It has methods to validate
all data and process all business rules.
When a user moves from one page to another of the application, we apply
the rules to the data in the page/form in order to decided whether the
user should be allowed to progress, or carry out the requested action.
Normally, we would return on the first failure and report that, but I
can see there would be cases for applying all the rules and reporting
all the failures. We would do this by calling all the appropriate
methods in the remote validation object, building up a message to return
as failures occur.
You could either return a null string on success, with the error message
(as built) as the return value on failure or, as we prefer, to return
true on success and throw an exception with the error message assigned
to the exception's message property, on failure. This latter means that
you must configure remoting to return error messages from remote
exceptions, of course, in your config file.
HTH
Peter
[quoted text, click to view] Alan Fisher wrote:
> Thanks Peter, but I am not talking about exceptions. I am talking about
> non-trivial validation errors which are 'expected'. e.g. data was
> incorrectly entered with validation rules performed via a stored procedure
> detecting the 'error'
>
> Alan
>
> "peter" <apvx95@dsl.pipex.com> wrote in message
> news:42e912b1$0$334$cc9e4d1f@news.dial.pipex.com...
>
>>Hi Alan,
>>
>>I set the Exception's Message property by appending to what's already
>>there, and then re-throw the exception.
>>
>>HTH
>>
>>Peter
>>
>>Alan Fisher wrote:
>>
>>>Hi Luke,
>>>
>>>Thanks for the reply. Maybe I didnt explain myself properly. I am not
>>>talking about exceptions as I am already using the application blocks for
>>>these. I am talking about validation messages (errors and warnings).
>>>These are expected errors where usually, if one occurs, you want to
>>>collect it and continue, collecting all of the errors (throughout the
>>>layers) until the processing ends. At the end, the UI reports all of the
>>>messages so the user can take action.
>>>
>>>Exceptions are different because they stop processing (unless they are
>>>handled) as a result of an exceptional circumstance
>>>
>>>Thanks
>>>Alan
>>>"[MSFT]" <lukezhan@online.microsoft.com> wrote in message
>>>news:J59uFsxkFHA.3120@TK2MSFTNGXA01.phx.gbl...
>>>
>>>
>>>>Hello Alan,
>>>>
>>>>If you don't want pass the exceptions between methods, another way may be
>>>>MSMQ. Your web service can put the exception information in MSMQ, and
>>>>client UI receives them. I suggest you may take a look at LOGGING
>>>>Application Block, it support log information in MSMQ:
>>>>
>>>>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html
>>>>/logging.asp?frame=true
>>>>
>>>>hope this help,
>>>>
>>>>Luke
>>>>
>>>>
>>>>
>>>>
>>>
>>>
I'm having the same problem. I have created a class ValidationResult which
looks like:
class ValidationResult
{
ValidationStatus Status;
ValidationItemCollection Items;
}
The ValidationItem is defined as below:
class ValidationItem
{
ValidationStatus Staus;
string Code; // Error code usually, but can be a warning, info or sth
else
string Message;
}
ValidationStatus is an enumeration which for the moment is defined as:
enum ValidationStatus
{
Success,
Failed
// Later can be added Warning, Info etc.
}
Now the problem is how to pass the ValidationResult object to the UI. I see
3 options:
1. throw an exeception which has a property of type ValidationResult. The UI
then can catch the exception and proceed. Looks a bit messy to me...
Pros: Force the UI to handel the validation.
Cons: Looks like a bad design. UI code would be messy...
2. Fire an event on a "global" object accessible from both UI and
components. "Recomment" the UI to attach an event handler...
Pros: UI code should be better organized...
Cons: UI is not forced to handle the event...
3. Use some kind of queue to add the ValidationResult objects from the
components and poll them from the UI.
Pros: ?
Cons: ?
Any thoughts are welcome.
Thanx,
Albert
[quoted text, click to view] "Alan Fisher" <Gobba@newsgroup.nospam> wrote in message
news:ezii4awkFHA.2852@TK2MSFTNGP14.phx.gbl...
>I am building a stateless distributed web application which has validation
>of information performed in many layers. Most of the validation will be
>repeated in both the UI and business layers as the code is structured to
>also expose functionality as a web service. More advanced validation will
>be done in both the business layer and data layer e.g. validating groups of
>related properties or related information in rows of data
>
> When validating the information for 'anticipated' problems (errors and
> warnings), I want to collect all of the various errors/warnings and report
> them back to the UI as some sort of collection. Ideally, I would prefer
> not to pass the collection between methods so was looking at possibly
> using a singleton but I would have to somehow isolate the collection per
> user's session since the app is 'mostly' stateless.
>
> I have searched the net and found many great articles on Exception
> Management but nothing detailed on validation. Can anyone recommend an
> approach or point me to some articles?
>
> TIA
> Alan
>
>
>
>
>