Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv877/src/Spring/Spring.Web/Web/UI
Modified Files:
MasterPage.cs Page.cs UserControl.cs
Added Files:
IValidationContainer.cs
Log Message:
SPRNET-558, SPRNET-559
introduced new IValidationContainer interface
--- NEW FILE: IValidationContainer.cs ---
(This appears to be a binary file; contents omitted.)
Index: Page.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI/Page.cs,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** Page.cs 5 Feb 2008 20:40:26 -0000 1.87
--- Page.cs 19 Mar 2008 12:07:15 -0000 1.88
***************
*** 75,79 ****
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Page : System.Web.UI.Page, IHttpHandler, IApplicationContextAware, ISharedStateAware, IProcessAware,
! ISupportsWebDependencyInjection, IWebDataBound
{
#region Constants
--- 75,79 ----
[AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class Page : System.Web.UI.Page, IHttpHandler, IApplicationContextAware, ISharedStateAware, IProcessAware,
! ISupportsWebDependencyInjection, IWebDataBound, IValidationContainer
{
#region Constants
***************
*** 1143,1147 ****
/// </summary>
/// <value>The validation errors container.</value>
! public IValidationErrors ValidationErrors
{
get { return validationErrors; }
--- 1143,1147 ----
/// </summary>
/// <value>The validation errors container.</value>
! public virtual IValidationErrors ValidationErrors
{
get { return validationErrors; }
Index: UserControl.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI/UserControl.cs,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** UserControl.cs 26 Feb 2008 19:06:11 -0000 1.51
--- UserControl.cs 19 Mar 2008 12:07:15 -0000 1.52
***************
*** 52,56 ****
/// <author>Aleksandar Seovic</author>
/// <version>$Id$</version>
! public class UserControl : System.Web.UI.UserControl, IApplicationContextAware, IWebDataBound, ISupportsWebDependencyInjection,IPostBackDataHandler
{
#region Static fields
--- 52,57 ----
/// <author>Aleksandar Seovic</author>
/// <version>$Id$</version>
! public class UserControl : System.Web.UI.UserControl, IApplicationContextAware, IWebDataBound, ISupportsWebDependencyInjection,
! IPostBackDataHandler,IValidationContainer
{
#region Static fields
***************
*** 587,591 ****
/// </summary>
/// <value>The validation errors container.</value>
! public IValidationErrors ValidationErrors
{
get { return validationErrors; }
--- 588,592 ----
/// </summary>
/// <value>The validation errors container.</value>
! public virtual IValidationErrors ValidationErrors
{
get { return validationErrors; }
Index: MasterPage.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI/MasterPage.cs,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** MasterPage.cs 1 Aug 2007 23:11:01 -0000 1.13
--- MasterPage.cs 19 Mar 2008 12:07:15 -0000 1.14
***************
*** 22,27 ****
--- 22,31 ----
using System;
+ using System.Collections;
+ using System.Collections.Specialized;
using System.Web.UI;
+ using Spring.Validation;
using Spring.Web.UI.Controls;
+ using IValidator = Spring.Validation.IValidator;
#if NET_2_0
***************
*** 96,104 ****
/// <author>Aleksandar Seovic</author>
/// <version>$Id$</version>
! public class MasterPage : System.Web.UI.MasterPage, IApplicationContextAware, ISupportsWebDependencyInjection
{
#region Instance Fields
private ILocalizer localizer;
private IMessageSource messageSource;
private IApplicationContext applicationContext;
--- 100,109 ----
/// <author>Aleksandar Seovic</author>
/// <version>$Id$</version>
! public class MasterPage : System.Web.UI.MasterPage, IApplicationContextAware, ISupportsWebDependencyInjection, IValidationContainer
{
#region Instance Fields
private ILocalizer localizer;
+ private IValidationErrors validationErrors = new ValidationErrors();
private IMessageSource messageSource;
private IApplicationContext applicationContext;
***************
*** 381,384 ****
--- 386,464 ----
#endregion
+ #region Validation support
+
+ /// <summary>
+ /// Evaluates specified validators and returns <c>True</c> if all of them are valid.
+ /// </summary>
+ /// <remarks>
+ /// <p>
+ /// Each validator can itself represent a collection of other validators if it is
+ /// an instance of <see cref="ValidatorGroup"/> or one of its derived types.
+ /// </p>
+ /// <p>
+ /// Please see the Validation Framework section in the documentation for more info.
+ /// </p>
+ /// </remarks>
+ /// <param name="validationContext">Object to validate.</param>
+ /// <param name="validators">Validators to evaluate.</param>
+ /// <returns>
+ /// <c>True</c> if all of the specified validators are valid, <c>False</c> otherwise.
+ /// </returns>
+ public bool Validate(object validationContext, params IValidator[] validators)
+ {
+ IDictionary contextParams = CreateValidatorParameters();
+ bool result = true;
+ foreach (IValidator validator in validators)
+ {
+ if (validator == null)
+ {
+ throw new ArgumentException("Validator is not defined.");
+ }
+ result = validator.Validate(validationContext, contextParams, this.validationErrors) && result;
+ }
+
+ return result;
+ }
+
+ /// <summary>
+ /// Gets the validation errors container.
+ /// </summary>
+ /// <value>The validation errors container.</value>
+ public virtual IValidationErrors ValidationErrors
+ {
+ get { return validationErrors; }
+ }
+
+ /// <summary>
+ /// Creates the validator parameters.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method can be overriden if you want to pass additional parameters
+ /// to the validation framework, but you should make sure that you call
+ /// this base implementation in order to add page, session, application,
+ /// request, response and context to the variables collection.
+ /// </para>
+ /// </remarks>
+ /// <returns>
+ /// Dictionary containing parameters that should be passed to
+ /// the data validation framework.
+ /// </returns>
+ protected virtual IDictionary CreateValidatorParameters()
+ {
+ IDictionary parameters = new ListDictionary();
+ parameters["page"] = this.Page;
+ parameters["usercontrol"] = this;
+ parameters["session"] = this.Session;
+ parameters["application"] = this.Application;
+ parameters["request"] = this.Request;
+ parameters["response"] = this.Response;
+ parameters["context"] = this.Context;
+
+ return parameters;
+ }
+
+ #endregion
+
#region Spring Page support
|