From 33fd079580b1a76738dab6890d671581664770fa Mon Sep 17 00:00:00 2001 From: eeichinger Date: Mon, 13 Oct 2008 14:07:40 +0000 Subject: [PATCH] added xmldocs for new result navigation support: sprnet-1040, sprnet-1052, sprnet-958, sprnet-567 --- src/Spring/Spring.Web/Spring.Web.2005.csproj | 10 + src/Spring/Spring.Web/Spring.Web.2008.csproj | 3 +- src/Spring/Spring.Web/Util/WebUtils.cs | 19 +- .../Web/Support/DefaultResultFactory.cs | 17 ++ .../Web/Support/DefaultResultWebNavigator.cs | 253 ++++++++++++++++++ .../Web/Support/IHierarchicalWebNavigator.cs | 8 + src/Spring/Spring.Web/Web/Support/IResult.cs | 56 ++++ .../Spring.Web/Web/Support/IResultFactory.cs | 44 +++ .../Web/Support/IResultWebNavigator.cs | 14 + .../Spring.Web/Web/Support/IWebNavigable.cs | 7 + .../Spring.Web/Web/Support/IWebNavigator.cs | 38 ++- src/Spring/Spring.Web/Web/Support/Result.cs | 79 ++++-- .../Web/Support/ResultFactoryRegistry.cs | 101 +++++++ .../Web/Support/ResultWebNavigator.cs | 169 ------------ .../Web/Support/WebFormsResultWebNavigator.cs | 206 ++++++++++++-- .../WebNavigableWebNavigatorAdapter.cs | 53 ++++ .../Spring.Web/Web/UI/Controls/Panel.cs | 39 ++- src/Spring/Spring.Web/Web/UI/MasterPage.cs | 10 +- src/Spring/Spring.Web/Web/UI/Page.cs | 16 +- src/Spring/Spring.Web/Web/UI/UserControl.cs | 10 +- ...istenceExceptionTranslationAdvisorTests.cs | 2 +- .../Spring.Web.Tests.2005.csproj | 1 + .../Spring.Web.Tests/Web/UI/PageTests.cs | 2 +- .../Web/UI/UserControlTests.cs | 4 +- 24 files changed, 910 insertions(+), 251 deletions(-) create mode 100644 src/Spring/Spring.Web/Web/Support/DefaultResultWebNavigator.cs delete mode 100644 src/Spring/Spring.Web/Web/Support/ResultWebNavigator.cs create mode 100644 src/Spring/Spring.Web/Web/Support/WebNavigableWebNavigatorAdapter.cs diff --git a/src/Spring/Spring.Web/Spring.Web.2005.csproj b/src/Spring/Spring.Web/Spring.Web.2005.csproj index 6fd4af08..80069f5f 100644 --- a/src/Spring/Spring.Web/Spring.Web.2005.csproj +++ b/src/Spring/Spring.Web/Spring.Web.2005.csproj @@ -123,6 +123,16 @@ Code + + + + + + + + + + diff --git a/src/Spring/Spring.Web/Spring.Web.2008.csproj b/src/Spring/Spring.Web/Spring.Web.2008.csproj index 1244b5cd..7d22f15a 100644 --- a/src/Spring/Spring.Web/Spring.Web.2008.csproj +++ b/src/Spring/Spring.Web/Spring.Web.2008.csproj @@ -133,6 +133,7 @@ + @@ -269,7 +270,7 @@ ASPXCodeBehind - + ASPXCodeBehind diff --git a/src/Spring/Spring.Web/Util/WebUtils.cs b/src/Spring/Spring.Web/Util/WebUtils.cs index 05b8aa62..8216bb7f 100644 --- a/src/Spring/Spring.Web/Util/WebUtils.cs +++ b/src/Spring/Spring.Web/Util/WebUtils.cs @@ -21,6 +21,7 @@ #region Imports using System; +using System.Web; using System.Web.UI; #endregion @@ -243,7 +244,7 @@ namespace Spring.Util /// /// Returns the 'logical' parent of the specified control. Technically when dealing with masterpages and control hierarchy, - /// the order goes controls->masterpage->page. But one often wants the more logical order controls->page->masterpage. + /// the order goes controls->masterpage->page. But one often wants the more logical order controls->page->masterpage. /// ///the control, who's parent is to be determined. ///the logical parent or null if the top of the hierarchy is reached. @@ -286,5 +287,21 @@ namespace Spring.Util return (control is System.Web.UI.MasterPage); #endif } + + /// + /// Encode for use in URLs. + /// + /// the text to be encoded. + /// the url-encoded + /// + /// This method may be used outside of a current request. If executed within a + /// request, is used. + /// will be used otherwise. + /// + public static string UrlEncode( string value ) + { + HttpContext ctx = HttpContext.Current; + return (ctx == null) ? HttpUtility.UrlEncode( value ) : ctx.Server.UrlEncode( value ); + } } } \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/DefaultResultFactory.cs b/src/Spring/Spring.Web/Web/Support/DefaultResultFactory.cs index d2ac0b03..dde70c01 100644 --- a/src/Spring/Spring.Web/Web/Support/DefaultResultFactory.cs +++ b/src/Spring/Spring.Web/Web/Support/DefaultResultFactory.cs @@ -24,8 +24,25 @@ namespace Spring.Web.Support { + /// + /// This result factory implementation creates instances from a given string representation. + /// + /// + /// For a larger example illustrating the customization of result processing, . + /// + /// + /// + /// + /// + /// Erich Eichinger public class DefaultResultFactory : IResultFactory { + /// + /// Create a new from the specified . + /// + /// the result mode. + /// the string representation of the result. + /// the instance created from . public IResult CreateResult(string resultMode, string resultText) { return new Result(resultMode, resultText); diff --git a/src/Spring/Spring.Web/Web/Support/DefaultResultWebNavigator.cs b/src/Spring/Spring.Web/Web/Support/DefaultResultWebNavigator.cs new file mode 100644 index 00000000..fd00bd11 --- /dev/null +++ b/src/Spring/Spring.Web/Web/Support/DefaultResultWebNavigator.cs @@ -0,0 +1,253 @@ +#region License + +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +#region Imports + +using System; +using System.Collections; +using Spring.Collections; +using Spring.Core; +using Spring.Util; + +#endregion + +namespace Spring.Web.Support +{ + /// + /// The default implementation of the interface. + /// + public class DefaultResultWebNavigator : IResultWebNavigator + { + private IWebNavigator _parentNavigator; + private bool _ignoreCase; + private IDictionary _results; + + /// + /// Indicates, whether result names are treated case sensitive by this navigator. + /// + public bool IsCaseSensitive + { + get { return !_ignoreCase; } + } + + /// + /// Get/Set the parent of this navigator. + /// + /// if this navigator already has a parent. + public virtual IWebNavigator ParentNavigator + { + get { return _parentNavigator; } + set + { + if (_parentNavigator != null) + { + throw new InvalidOperationException("Can't set parent navigator because this navigator already has a parent"); + } + _parentNavigator = value; + } + } + + /// + /// Gets or sets map of result names to instances or their textual representations. + /// See for information on parsing textual representations. + /// + /// + /// + /// + /// + public IDictionary Results + { + get + { + return _results; + } + set + { + _results = CreateResultsDictionary( value ); + } + } + + /// + /// Creates and initializes a new instance. + /// + public DefaultResultWebNavigator() + : this( null, null, true ) + { } + + /// + /// Creates and initializes a new instance. + /// + /// the parent of this instance. May be null. + /// a dictionary of result name to result mappings. May be null. + /// sets, how this navigator treats case sensitivity of result names + public DefaultResultWebNavigator( IWebNavigator parent, IDictionary initialResults, bool ignoreCase ) + { + this._parentNavigator = parent; + this._ignoreCase = ignoreCase; + this._results = CreateResultsDictionary( initialResults ); + } + + /// + /// Create the dictionary instance to be used by this navigator component. + /// + /// a dictionary of intitial result mappings + /// the dictionary, that will be used by this navigator. + /// + /// Implementors may override this for creating custom dictionaries. + /// + protected virtual IDictionary CreateResultsDictionary( IDictionary initialResults ) + { + IDictionary newResults = (_ignoreCase) ? new CaseInsensitiveHashtable() : new Hashtable(); + if (initialResults != null) + { + foreach (DictionaryEntry entry in initialResults) + { + newResults[entry.Key.ToString()] = entry.Value; + } + } + return newResults; + } + + /// + /// Determines, whether this navigator or one of its parents can + /// navigate to the destination specified in . + /// + /// the name of the navigation destination + /// true, if this navigator can navigate to the destination. + public virtual bool CanNavigateTo( string destination ) + { + if (_results.Contains( destination )) + { + return true; + } + return (ParentNavigator != null) ? ParentNavigator.CanNavigateTo( destination ) : false; + } + + /// + /// Redirects user to a URL mapped to specified result name. + /// + /// Name of the result. + /// the instance that issued this request + /// The context to use for evaluating the SpEL expression in the Result. + public virtual void NavigateTo( string destination, object sender, object context ) + { + IResult result = GetResult( destination ); + if (result == null) + { + if (ParentNavigator != null) + { + ParentNavigator.NavigateTo( destination, sender, context ); + return; + } + HandleUnknownDestination(destination, sender, context); + return; + } + + // If no context, 'sender' is context + if (context == null) + { + context = sender; + } + result.Navigate( context ); + } + + /// + /// Returns a redirect url string that points to the + /// defined by this + /// result evaluated using this Page for expression + /// + /// Name of the result. + /// the instance that issued this request + /// The context to use for evaluating the SpEL expression in the Result + /// A redirect url string. + public virtual string GetResultUri( string resultName, object sender, object context ) + { + IResult result = GetResult( resultName ); + if (result == null) + { + if (ParentNavigator != null) + { + return result.GetRedirectUri( context ); + } + return HandleUnknownDestination( resultName, sender, context ); + } + + // If no context, 'sender' is context + if (context == null) + { + context = sender; + } + return result.GetRedirectUri( context ); + } + + /// + /// Obtain the named result instance from the dictionary. If necessary, the actual representation of the result + /// will be converted to an instance by this method. + /// + /// + /// + protected IResult GetResult( string name ) + { + object val = _results[name]; + if (val == null) + { + return null; + } + else if (val is IResult) + { + return (IResult)val; + } + else if (val is String) + { + return ResultFactoryRegistry.CreateResult( (string)val ); + } + + return HandleUnknownResultType(name, val); + } + + /// + /// Handle an unknown result object. + /// + /// the name of the result + /// the result instance obtained from the dictionary + /// + /// By default, this method throws a . + /// + protected virtual IResult HandleUnknownResultType(string name, object val) + { + throw new TypeMismatchException("Unable to create result object. Please use either String or Result instances to define results." ); + } + + /// + /// Handle an unknown destination. + /// + /// the destination that could not be resolved. + /// the sender that issued the request + /// the context to be used for evaluating any dynamic parts of the destination + /// the uri as being returned from + /// + /// By default, this method throws a . + /// + protected virtual string HandleUnknownDestination( string destination, object sender, object context ) + { + throw new ArgumentOutOfRangeException( "destination", string.Format( "No mapping found for the specified destination '{0}'.", destination ) ); + } + } +} \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/IHierarchicalWebNavigator.cs b/src/Spring/Spring.Web/Web/Support/IHierarchicalWebNavigator.cs index f3932e52..8783edb8 100644 --- a/src/Spring/Spring.Web/Web/Support/IHierarchicalWebNavigator.cs +++ b/src/Spring/Spring.Web/Web/Support/IHierarchicalWebNavigator.cs @@ -24,8 +24,16 @@ namespace Spring.Web.Support { + /// + /// An extension of that must be implemented by + /// navigators that can be part of a hierarchy. + /// + /// Erich Eichinger public interface IHierarchicalWebNavigator : IWebNavigator { + /// + /// If any, get the parent navigator of the current navigator instance. May be null. + /// IWebNavigator ParentNavigator { get; } } } \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/IResult.cs b/src/Spring/Spring.Web/Web/Support/IResult.cs index cb03e182..d9abab2a 100644 --- a/src/Spring/Spring.Web/Web/Support/IResult.cs +++ b/src/Spring/Spring.Web/Web/Support/IResult.cs @@ -1,8 +1,64 @@ +#region License + +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +#region Imports + +using System.Web; +using Spring.Web.UI; + +#endregion + namespace Spring.Web.Support { + /// + /// An encapsulates concrete navigation logic. Usually executing a + /// result will invoke or . + /// + /// + /// For a larger example illustrating the customization of result processing . + /// + /// + /// + /// + /// + /// + /// + /// Erich Eichinger public interface IResult { + /// + /// Execute the result logic within the given . + /// + /// the context to evaluate this request in. void Navigate( object context ); + /// + /// Returns an url representation of the result logic within the given . + /// + /// the context to evaluate this request in. + /// the url corresponding to the result instance. + /// + /// The returned url is not necessarily fully qualified nor absolute. Returned urls may be relative to the + /// given context.
+ /// To produce a client-usable url, consider applying e.g. or + /// before writing the result url to the response. + ///
string GetRedirectUri( object context ); } } \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/IResultFactory.cs b/src/Spring/Spring.Web/Web/Support/IResultFactory.cs index 749dd61a..426078bc 100644 --- a/src/Spring/Spring.Web/Web/Support/IResultFactory.cs +++ b/src/Spring/Spring.Web/Web/Support/IResultFactory.cs @@ -1,7 +1,51 @@ +#region License + +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +#region Imports + +#endregion + namespace Spring.Web.Support { + /// + /// A result factory is responsible for create an instance from a given string representation. + /// + /// + /// For a larger example illustrating the customization of result processing, . + /// + /// + /// + /// + /// + /// Erich Eichinger public interface IResultFactory { + /// + /// Create an instance from the given string representation. + /// + /// the resultMode that caused triggering this factory. + /// the remainder string to be interpreted and converted into an . + /// An instance. Must never be null! + /// + /// Note to implementors: This method must never return null. Instead exceptions should be thrown. + /// IResult CreateResult( string resultMode, string resultText ); } } \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/IResultWebNavigator.cs b/src/Spring/Spring.Web/Web/Support/IResultWebNavigator.cs index f125c787..15cea2e4 100644 --- a/src/Spring/Spring.Web/Web/Support/IResultWebNavigator.cs +++ b/src/Spring/Spring.Web/Web/Support/IResultWebNavigator.cs @@ -26,8 +26,22 @@ using System.Collections; namespace Spring.Web.Support { + /// + /// Defines the interface, all hierarchical navigators capable of + /// dealing with instances must implement. + /// public interface IResultWebNavigator : IHierarchicalWebNavigator { + /// + /// Contains the mappings of navigation destination names to + /// instances or their corresponding textual representations.
+ /// See for more information on how textual representations are resolved. + ///
+ /// + /// + /// + /// + /// IDictionary Results { get; set; } } } \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/IWebNavigable.cs b/src/Spring/Spring.Web/Web/Support/IWebNavigable.cs index 4717d345..0a9e69ab 100644 --- a/src/Spring/Spring.Web/Web/Support/IWebNavigable.cs +++ b/src/Spring/Spring.Web/Web/Support/IWebNavigable.cs @@ -26,8 +26,15 @@ namespace Spring.Web.Support { + /// + /// Any component participating in the navigation infrastructure must implement this interface. + /// + /// Erich Eichinger public interface IWebNavigable { + /// + /// Return the associated with this component. + /// IWebNavigator WebNavigator { get; } } } \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/IWebNavigator.cs b/src/Spring/Spring.Web/Web/Support/IWebNavigator.cs index cf452099..677c7c34 100644 --- a/src/Spring/Spring.Web/Web/Support/IWebNavigator.cs +++ b/src/Spring/Spring.Web/Web/Support/IWebNavigator.cs @@ -22,18 +22,44 @@ #endregion +using System; + namespace Spring.Web.Support { + /// + /// Any component capable of navigating and participating in the navigation logic must implement this interface. + /// + /// + /// + /// + /// + /// Erich Eichinger public interface IWebNavigator { /// /// Determines, whether this navigator or one of its parents can - /// navigate to the result specified in . + /// navigate to the destination specified in . /// - /// the name of the result - /// true, if this navigator or one of its parents can navigate to the result. - bool CanNavigateTo( string resultName ); - void NavigateTo( string resultName, object context ); - string GetResultUri( string resultName, object context ); + /// the name of the navigation destination + /// true, if this navigator can navigate to the destination. + bool CanNavigateTo( string destination ); + + /// + /// Instruct the navigator to navigate to the specified navigation destination. + /// + /// the destination to navigate to. + /// the sender that issued the navigation request. + /// the context to evaluate this navigation request in. + /// if this navigator cannot navigate to the specified (). + void NavigateTo( string destination, object sender, object context ); + + /// + /// Creates an uri poiniting to the specified navigation destination. + /// + /// the destination to navigate to. + /// the sender that issued the navigation request. + /// the context to evaluate this navigation request in. + /// if this navigator cannot navigate to the specified (). + string GetResultUri( string destination, object sender, object context ); } } \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/Result.cs b/src/Spring/Spring.Web/Web/Support/Result.cs index 086a3972..ae02c78f 100644 --- a/src/Spring/Spring.Web/Web/Support/Result.cs +++ b/src/Spring/Spring.Web/Web/Support/Result.cs @@ -288,9 +288,9 @@ namespace Spring.Web.Support foreach (DictionaryEntry entry in this.parameters) { string value = entry.Value.ToString(); - if (IsRuntimeExpression( value )) + if (IsSpELRuntimeExpression( value )) { - contextDictionary[entry.Key] = ResolveRuntimeExpression( context, value ); + contextDictionary[entry.Key] = ResolveValueIfNecessary( context, value ); } else { @@ -333,8 +333,8 @@ namespace Spring.Web.Support resolvedParameters = new CaseInsensitiveHashtable(); foreach (DictionaryEntry entry in this.Parameters) { - object key = ResolveRuntimeExpressionIfNecessary( context, entry.Key.ToString() ); - object value = ResolveRuntimeExpressionIfNecessary( context, entry.Value.ToString() ); + object key = ResolveValueIfNecessary( context, entry.Key.ToString() ); + object value = ResolveValueIfNecessary( context, entry.Value.ToString() ); resolvedParameters[key] = value; } } @@ -342,6 +342,12 @@ namespace Spring.Web.Support return BuildUrl( path, resolvedParameters ); } + /// + /// Construct the actual url to be executed or returned. + /// + /// the already evaluated + /// the already evaluated parameters. + /// the url to be returned by protected virtual string BuildUrl( string resolvedPath, IDictionary resolvedParameters ) { StringBuilder url = new StringBuilder( 256 ); @@ -351,43 +357,63 @@ namespace Spring.Web.Support char separator = '?'; foreach (DictionaryEntry entry in resolvedParameters) { - url.Append( separator ); - url.Append( BuildUrlParameter( entry.Key.ToString(), entry.Value.ToString() ) ); + url.Append( separator ); + url = BuildUrlParameter( url, entry.Key.ToString(), entry.Value.ToString() ); separator = '&'; } } return url.ToString(); } - protected virtual string BuildUrlParameter( string key, string value ) + /// + /// Append the url parameter to the url being constructed. + /// + /// the containing the url constructed so far. + /// the parameter key + /// the parameter value + /// the to use for further url construction. + protected virtual StringBuilder BuildUrlParameter( StringBuilder url, string key, string value ) { - return UrlEncode( key ) + "=" + UrlEncode( value ); + url.Append( WebUtils.UrlEncode( key ) ) + .Append( '=' ) + .Append( WebUtils.UrlEncode( value ) ); + + return url; } - protected static string UrlEncode( string value ) + /// + /// Evaluates within and returns the evaluation result. + /// + /// the context to be used for evaluation. + /// the string that might need evaluation + /// the evaluation result. Unodified if no evalution occured. + protected virtual object ResolveValueIfNecessary( object context, string value ) { - HttpContext ctx = HttpContext.Current; - return (ctx == null) ? HttpUtility.UrlEncode( value ) : ctx.Server.UrlEncode( value ); + return ResolveSpELRuntimeExpressionIfNecessary( context, value ); } - protected object ResolveRuntimeExpressionIfNecessary( object context, string value ) - { - if (IsRuntimeExpression( value )) - { - return ResolveRuntimeExpression( context, value ); - } - return value; - } - - private static bool IsRuntimeExpression( string value ) + /// + /// Checks, if value is a SpEL expression ${expression} or %{expression}. + /// + private static bool IsSpELRuntimeExpression( string value ) { // allow for 2 alternative prefixes (SPRNET-864) return (value.StartsWith( "${" ) || value.StartsWith( "%{" )) && value.EndsWith( "}" ); } - private static object ResolveRuntimeExpression( object context, string value ) + /// + /// If is a SpEL expression (${expression} or %{expression}), evaluates + /// the value against . + /// + protected static object ResolveSpELRuntimeExpressionIfNecessary( object context, string value ) { - return ExpressionEvaluator.GetValue( context, value.Substring( 2, value.Length - 3 ) ); + AssertUtils.ArgumentNotNull(value, "value"); + + if (IsSpELRuntimeExpression( value )) + { + return ExpressionEvaluator.GetValue( context, value.Substring( 2, value.Length - 3 ) ); + } + return value; } /// @@ -443,9 +469,14 @@ namespace Spring.Web.Support } } + /// + /// Resolves dynamic expression contained in if any by calling . + /// + /// the context to be used for evaluating the expression + /// the evaluated expression protected string GetResolvedTargetPage( object context ) { - return ResolveRuntimeExpressionIfNecessary( context, TargetPage ).ToString(); + return ResolveValueIfNecessary( context, TargetPage ).ToString(); } /// diff --git a/src/Spring/Spring.Web/Web/Support/ResultFactoryRegistry.cs b/src/Spring/Spring.Web/Web/Support/ResultFactoryRegistry.cs index a437ab38..c7380834 100644 --- a/src/Spring/Spring.Web/Web/Support/ResultFactoryRegistry.cs +++ b/src/Spring/Spring.Web/Web/Support/ResultFactoryRegistry.cs @@ -24,11 +24,65 @@ using System; using System.Collections; using Spring.Collections; using Spring.Util; +using Spring.Web.UI; #endregion namespace Spring.Web.Support { + /// + /// A result factory is responsible for create an instance from a given string representation. + /// + /// + /// + /// Factories get registered with the for a certain resultMode string. + /// uses for converting strings into instances + /// implementing the corresponding navigation logic. + /// + /// + /// Result string representations are always of the form:
+ /// "<resultmode>:<textual result representation>"
+ /// Calling on the registry will cause the registry to first extract the leading resultmode to obtain + /// the corresponding instance and handle the actual instantiation by delegating to + /// . + ///
+ /// + /// The following example illustrates the usual flow: + /// + /// class MySpecialResultLogic : IResult + /// { + /// ... + /// } + /// + /// class MySpecialResultLogicFactory : IResultFactory + /// { + /// IResult Create( string mode, string expression ) { /* ... convert 'expression' into + /// MySpecialResultLogic */ } + /// } + /// + /// // register with global factory + /// ResultFactoryRegistry.RegisterResultFactory( "mySpecialMode", new MySpecialResultLogicFactory ); + /// + /// // configure your Results + /// <object type="mypage.aspx"> + /// <property name="Results"> + /// <dictionary> + /// <entry key="continue" value="mySpecialMode:<some MySpecialResultLogic string representation>" /> + /// </dictionary> + /// </property> + /// + /// // on your page call + /// myPage.SetResult("continue"); + /// + /// + ///
+ /// + /// + /// + /// + /// + /// + /// Erich Eichinger public class ResultFactoryRegistry { private static readonly IDictionary s_registeredFactories = new CaseInsensitiveHashtable(); @@ -39,6 +93,9 @@ namespace Spring.Web.Support Reset(); } + /// + /// Resets the factory registry to its defaults. Mainly used for unit testing. + /// public static void Reset() { s_defaultFactory = null; @@ -52,21 +109,45 @@ namespace Spring.Web.Support } } + /// + /// Returns the current set by . Will never be null. + /// + /// + /// The default factory is responsible for handling any unknown result modes. + /// public static IResultFactory DefaultResultFactory { get { return s_defaultFactory; } } + /// + /// Set a new default factory + /// + /// the new default factory instance. Must not be null. + /// the previous default factory. public static IResultFactory SetDefaultFactory(IResultFactory resultFactory) { AssertUtils.ArgumentNotNull(resultFactory, "resultFactory"); + IResultFactory prevFactory = s_defaultFactory; s_defaultFactory = resultFactory; return prevFactory; } + /// + /// Registers a for the specified . + /// + /// the resultMode. Must not be null. + /// the factory respponsible for handling results. Must not be null. + /// the factory previously registered for the specified , if any. + /// + /// See overview for more information. + /// public static IResultFactory RegisterResultMode( string resultMode, IResultFactory resultFactory ) { + AssertUtils.ArgumentHasText(resultMode, "resultMode"); + AssertUtils.ArgumentNotNull(resultFactory, "resultFactory"); + lock (s_registeredFactories.SyncRoot) { IResultFactory prevFactory = (IResultFactory) s_registeredFactories[resultMode]; @@ -75,8 +156,28 @@ namespace Spring.Web.Support } } + /// + /// Creates a result from the specified by extracting the result mode from + /// the text and delegating to a corresponding , if any. + /// + /// the 'resultmode'-prefixed textual representation of the result instance to create. + /// + /// the instance corresponding to the textual represenation, + /// created by the + /// + /// + /// if either is null or returned null. + /// + /// This method guarantees that the return value will always be non-null.
+ /// must always be of the form "<resultmode>:<textual result representation>". + /// The resultmode will be extracted and the corresponding (previously registered + /// using ) is called to actually create the instance. If no factory matches + /// resultmode, the call is handled to the . + ///
public static IResult CreateResult( string resultText ) { + AssertUtils.ArgumentNotNull(resultText, "resultText"); + IResultFactory resultFactory = null; string resultMode = null; diff --git a/src/Spring/Spring.Web/Web/Support/ResultWebNavigator.cs b/src/Spring/Spring.Web/Web/Support/ResultWebNavigator.cs deleted file mode 100644 index 4219624b..00000000 --- a/src/Spring/Spring.Web/Web/Support/ResultWebNavigator.cs +++ /dev/null @@ -1,169 +0,0 @@ -#region License - -/* - * Copyright 2002-2008 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#endregion - -#region Imports - -using System; -using System.Collections; -using Spring.Collections; -using Spring.Core; -using Spring.Util; - -#endregion - -namespace Spring.Web.Support -{ - public class ResultWebNavigator : IResultWebNavigator - { - private IWebNavigator _parentNavigator; - private bool _ignoreCase; - private IDictionary _results; - - public bool IsCaseSensitive - { - get { return !_ignoreCase; } - } - - public virtual IWebNavigator ParentNavigator - { - get { return _parentNavigator; } - set - { - if (_parentNavigator != null) - { - AssertUtils.ArgumentNotNull( _parentNavigator, "Parent", "Navigator already has a parent" ); - } - _parentNavigator = value; - } - } - - /// - /// Gets or sets map of result names to target URLs - /// - public IDictionary Results - { - get - { - return _results; - } - set - { - _results = CreateResultsDictionary(value); - } - } - - public ResultWebNavigator() - :this(null, null, true) - {} - - public ResultWebNavigator( IWebNavigator parent, IDictionary results, bool ignoreCase ) - { - this._parentNavigator = parent; - this._ignoreCase = ignoreCase; - this._results = CreateResultsDictionary( results ); - } - - protected virtual IDictionary CreateResultsDictionary( IDictionary initialResults ) - { - IDictionary newResults = (_ignoreCase) ? new CaseInsensitiveHashtable() : new Hashtable(); - if (initialResults != null) - { - foreach(DictionaryEntry entry in initialResults) - { - newResults[entry.Key.ToString()] = entry.Value; - } - } - return newResults; - } - - public virtual bool CanNavigateTo( string resultName ) - { - if (_results.Contains( resultName )) - { - return true; - } - return (ParentNavigator != null) ? ParentNavigator.CanNavigateTo( resultName ) : false; - } - - /// - /// Redirects user to a URL mapped to specified result name. - /// - /// Name of the result. - /// The context to use for evaluating the SpEL expression in the Result. - public virtual void NavigateTo( string resultName, object context ) - { - IResult result = GetResult( resultName ); - if (result == null) - { - if (ParentNavigator != null) - { - ParentNavigator.NavigateTo( resultName, context ); - return; - } - throw new ArgumentException( string.Format( "No result mapping found for the specified name '{0}'.", resultName ), "resultName" ); - } - result.Navigate( context ); - } - - /// - /// Returns a redirect url string that points to the - /// defined by this - /// result evaluated using this Page for expression - /// - /// Name of the result. - /// The context to use for evaluating the SpEL expression in the Result - /// A redirect url string. - public virtual string GetResultUri( string resultName, object context ) - { - IResult result = GetResult( resultName ); - if (result == null) - { - if (ParentNavigator != null) - { - return result.GetRedirectUri( context ); - } - throw new ArgumentException( string.Format( "No result mapping found for the specified name '{0}'.", resultName ), "resultName" ); - } - return result.GetRedirectUri( context ); - } - - protected IResult GetResult( string name ) - { - object val = _results[name]; - if (val == null) - { - return null; - } - else if (val is IResult) - { - return (IResult)val; - } - else if (val is String) - { - return ResultFactoryRegistry.CreateResult( (string)val ); - } - else - { - throw new TypeMismatchException( - "Unable to create result object. Please use either String or Result instances to define results." ); - } - } - } -} \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/Support/WebFormsResultWebNavigator.cs b/src/Spring/Spring.Web/Web/Support/WebFormsResultWebNavigator.cs index 6b035054..e7cecdcc 100644 --- a/src/Spring/Spring.Web/Web/Support/WebFormsResultWebNavigator.cs +++ b/src/Spring/Spring.Web/Web/Support/WebFormsResultWebNavigator.cs @@ -20,6 +20,7 @@ #region Imports +using System; using System.Collections; using System.Web.UI; using Spring.Util; @@ -32,20 +33,70 @@ namespace Spring.Web.Support /// An implementation of specific for s. /// The navigator hierarchy equals the control hierarchy when using a . ///
- public class WebFormsResultWebNavigator : ResultWebNavigator + /// + /// + /// This implementation supports 2 different navigator hierarchies: + ///
    + ///
  • The default hierarchy defined by
  • + ///
  • The hierarchy defined by a web form's hierarchy.
  • + ///
+ ///
+ /// + /// This implementation always checks the standard hierarchy first and - if a destination cannot be resolved, falls back + /// to the control hierarchy for resolving a specified navigation destination. + /// + ///
+ public class WebFormsResultWebNavigator : DefaultResultWebNavigator { + /// + /// Holds the result match from . + /// + protected class NavigableControlInfo + { + /// + /// The matching control + /// + public readonly Control Control; + /// + /// The instance associated with the control. May be null. + /// + public readonly IWebNavigator WebNavigator; + + /// + /// Initializes the new match instance. + /// + /// the matching control. Must not be null! + public NavigableControlInfo( Control control ) + { + AssertUtils.ArgumentNotNull(control, "control"); + + Control = control; + + if (Control is IWebNavigable) + { + WebNavigator = ((IWebNavigable)Control).WebNavigator; + } + else if (Control is IWebNavigator) + { + WebNavigator = (IWebNavigator)control; + } + } + } + /// /// Finds the next up the control hierarchy, /// starting at the specified . /// /// /// This method checks both, for controls implementing or . In addition - /// when MasterPages are used, it interprets the control hierarchy as control->page->masterpage. + /// when MasterPages are used, it interprets the control hierarchy as control->page->masterpage. (). /// /// the control to start the search with. /// include checking the control itself or start search with its parent. - /// If found, the next up the hierarchy. null otherwise - public static IWebNavigator FindWebNavigator( Control control, bool includeSelf ) + /// requires s to hold a valid instance. + /// If found, the next or . + /// null otherwise + protected static NavigableControlInfo FindNavigableParent( Control control, bool includeSelf, bool restrictToValidNavigatorsOnly ) { while (control != null) { @@ -58,40 +109,151 @@ namespace Spring.Web.Support if (control is IWebNavigable || control is IWebNavigator) { - return (control is IWebNavigable) ? ((IWebNavigable)control).WebNavigator : (IWebNavigator)control; + NavigableControlInfo nci = new NavigableControlInfo(control); + if (!restrictToValidNavigatorsOnly) + { + return nci; + } + if (nci.WebNavigator != null) + { + return nci; + } } } return null; } - private Control _owner; + private readonly Control _owner; + + /// + /// The that this is associated with. + /// + public Control Owner + { + get { return _owner; } + } /// /// Creates a new instance of a for the specified control. /// /// the control to be associated with this navigator. - /// a dictionary containing results - /// determines, whether to interpret result names case-sensitive or not. - public WebFormsResultWebNavigator( Control owner, IDictionary results, bool ignoreCase ) - : base( null, results, ignoreCase ) - { - AssertUtils.ArgumentNotNull(owner, "owner"); + /// the direct parent of this navigator + /// a dictionary containing results + /// specifies how to handle case for destination names. + public WebFormsResultWebNavigator( Control owner, IWebNavigator parent, IDictionary initialResults, bool ignoreCase ) + : base( parent, initialResults, ignoreCase ) + { + AssertUtils.ArgumentNotNull( owner, "owner" ); _owner = owner; } - public override IWebNavigator ParentNavigator + /// + /// Determines, whether this navigator or one of its parents can + /// navigate to the destination specified in . + /// + /// the name of the navigation destination + /// true, if this navigator can navigate to the destination. + public override bool CanNavigateTo( string destination ) + { + return CheckCanNavigate( destination, true ); + } + + /// + /// Check, whether this navigator can navigate to the specified . + /// + /// the destination name to check. + /// + /// whether the check shall include the control hierarchy or + /// the standard hierarchy only. + /// + protected bool CheckCanNavigate( string destination, bool includeControlHierarchy ) + { + // check the default path + if (base.CanNavigateTo( destination )) + { + return true; + } + + // include checking the control hierarchy + if (includeControlHierarchy) + { + NavigableControlInfo nci = FindNavigableParent( this._owner, false, true ); + if (nci != null) + { + // when delegating upwards, the control containing the matching result + // will appear as sender - this makes dealing with expressions more "natural". + return nci.WebNavigator.CanNavigateTo( destination ); + } + } + + return false; + } + + /// + /// Returns a redirect url string that points to the + /// defined by this + /// result evaluated using this Page for expression + /// + /// Name of the result. + /// the instance that issued this request + /// The context to use for evaluating the SpEL expression in the Result + /// A redirect url string. + public override string GetResultUri( string destination, object sender, object context ) + { + if (this.CheckCanNavigate( destination, false )) + { + return base.GetResultUri( destination, sender, context ); + } + + NavigableControlInfo nci = FindNavigableParent( this._owner, false, true ); + if (nci != null) + { + // when delegating upwards, the control containing the matching result + // will appear as sender - this makes dealing with expressions more "natural". + return nci.WebNavigator.GetResultUri( destination, nci.Control, context ); + } + + return HandleUnknownDestination( destination, sender, context ); + } + + /// + /// Redirects user to a URL mapped to specified result name. + /// + /// Name of the result. + /// the instance that issued this request + /// The context to use for evaluating the SpEL expression in the Result. + public override void NavigateTo( string destination, object sender, object context ) + { + if (this.CheckCanNavigate( destination, false )) + { + base.NavigateTo( destination, sender, context ); + return; + } + + NavigableControlInfo nci = FindNavigableParent( this._owner, false, true ); + if (nci != null) + { + // when delegating upwards, the control containing the matching result + // will appear as sender - this makes dealing with expressions more "natural". + nci.WebNavigator.NavigateTo( destination, nci.Control, context ); + return; + } + + HandleUnknownDestination( destination, sender, context ); + } + + /// + /// Return the next available within + /// this control's parent hierarchy. + /// + public IWebNavigator ParentControlNavigator { get { - if (base.ParentNavigator == null) - { - base.ParentNavigator = FindWebNavigator(_owner, false); - } - return base.ParentNavigator; - } - set - { - throw new System.NotSupportedException("cannot set parent navigator on a WebFormsResultWebNavigator"); + // nci.WebNavigator is guaranteed to be non-null! + NavigableControlInfo nci = FindNavigableParent( this._owner, false, true ); + if (nci == null) return null; + return nci.WebNavigator; } } } diff --git a/src/Spring/Spring.Web/Web/Support/WebNavigableWebNavigatorAdapter.cs b/src/Spring/Spring.Web/Web/Support/WebNavigableWebNavigatorAdapter.cs new file mode 100644 index 00000000..0a7131fd --- /dev/null +++ b/src/Spring/Spring.Web/Web/Support/WebNavigableWebNavigatorAdapter.cs @@ -0,0 +1,53 @@ +#region License + +/* + * Copyright 2002-2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#endregion + +#region Imports + +#endregion + +namespace Spring.Web.Support +{ + /// + /// Adapts a concrete instance as a . + /// + /// Erich Eichinger + public class WebNavigableWebNavigatorAdapter : IWebNavigable + { + private readonly IWebNavigator _resultNavigator; + + /// + /// Create a new adapter instance, wrapping the specified + /// into a interface. + /// + /// the instance to be adapted. May be null. + public WebNavigableWebNavigatorAdapter(IWebNavigator resultNavigator) + { + _resultNavigator = resultNavigator; + } + + /// + /// Returns the wrapped that was passed into . + /// + public IWebNavigator WebNavigator + { + get { return _resultNavigator; } + } + } +} \ No newline at end of file diff --git a/src/Spring/Spring.Web/Web/UI/Controls/Panel.cs b/src/Spring/Spring.Web/Web/UI/Controls/Panel.cs index e16aeb87..0a52c5d9 100644 --- a/src/Spring/Spring.Web/Web/UI/Controls/Panel.cs +++ b/src/Spring/Spring.Web/Web/UI/Controls/Panel.cs @@ -90,6 +90,13 @@ namespace Spring.Web.UI.Controls private bool _renderContainerTag; private string _visibleConditionExpression; + /// + /// An optional SpEL expression to control this Panel's state. + /// + /// + /// This panel instance is the context for evaluating the given expression. If no expression is specified, visibility behavior + /// reverts to standard behavior. + /// public string VisibleIf { get { return _visibleConditionExpression; } @@ -116,24 +123,38 @@ namespace Spring.Web.UI.Controls } /// - /// Overridden to suppress rendering this control's tag + /// Overridden to set according to if necessary. /// - /// - protected override void Render(HtmlTextWriter writer) + protected override void OnPreRender( EventArgs e ) { - bool visible = (_visibleConditionExpression != null) + this.Visible = (_visibleConditionExpression != null) ? Spring.Expressions.ExpressionEvaluator.GetValue(this, _visibleConditionExpression).Equals(true) : this.Visible; - if (!visible) return; + base.OnPreRender( e ); + } - if (_renderContainerTag) + /// + ///Renders the HTML opening tag of the control to the specified writer. + /// + ///An that represents the output stream to render HTML content on the client. + public override void RenderBeginTag( HtmlTextWriter writer ) + { + if (this.RenderContainerTag) { - base.Render(writer); + base.RenderBeginTag( writer ); } - else + } + + /// + ///Renders the HTML closing tag of the control to the specified writer. + /// + ///An that represents the output stream to render HTML content on the client. + public override void RenderEndTag( HtmlTextWriter writer ) + { + if (this.RenderContainerTag) { - base.RenderContents(writer); + base.RenderEndTag( writer ); } } diff --git a/src/Spring/Spring.Web/Web/UI/MasterPage.cs b/src/Spring/Spring.Web/Web/UI/MasterPage.cs index d50f8c60..ee7666b0 100644 --- a/src/Spring/Spring.Web/Web/UI/MasterPage.cs +++ b/src/Spring/Spring.Web/Web/UI/MasterPage.cs @@ -437,7 +437,7 @@ namespace Spring.Web.UI /// protected virtual void InitializeNavigationSupport() { - webNavigator = new WebFormsResultWebNavigator(this, null, true); + webNavigator = new WebFormsResultWebNavigator(this, null, null, true); } /// @@ -526,7 +526,7 @@ namespace Spring.Web.UI /// Result name. protected void SetResult( string resultName ) { - WebNavigator.NavigateTo( resultName, this ); + WebNavigator.NavigateTo( resultName, this, null ); } @@ -537,7 +537,7 @@ namespace Spring.Web.UI /// The context to use for evaluating the SpEL expression in the Result. protected void SetResult( string resultName, object context ) { - WebNavigator.NavigateTo( resultName, context ); + WebNavigator.NavigateTo( resultName, this, context ); } @@ -550,7 +550,7 @@ namespace Spring.Web.UI /// A redirect url string. protected string GetResultUrl( string resultName ) { - return ResolveUrl( WebNavigator.GetResultUri( resultName, this ) ); + return ResolveUrl( WebNavigator.GetResultUri( resultName, this, null ) ); } /// @@ -563,7 +563,7 @@ namespace Spring.Web.UI /// A redirect url string. protected string GetResultUrl( string resultName, object context ) { - return ResolveUrl( WebNavigator.GetResultUri( resultName, context ) ); + return ResolveUrl( WebNavigator.GetResultUri( resultName, this, context ) ); } #endregion diff --git a/src/Spring/Spring.Web/Web/UI/Page.cs b/src/Spring/Spring.Web/Web/UI/Page.cs index e93280c7..c6cbb611 100644 --- a/src/Spring/Spring.Web/Web/UI/Page.cs +++ b/src/Spring/Spring.Web/Web/UI/Page.cs @@ -136,6 +136,12 @@ namespace Spring.Web.UI #region Page lifecycle methods + /// + /// Creates and initializes the new page instance. + /// + /// + /// Calls . + /// public Page() { InitializeNavigationSupport(); @@ -1044,7 +1050,7 @@ namespace Spring.Web.UI /// protected virtual void InitializeNavigationSupport() { - webNavigator = new WebFormsResultWebNavigator( this, null, true ); + webNavigator = new WebFormsResultWebNavigator( this, null, null, true ); } /// @@ -1136,7 +1142,7 @@ namespace Spring.Web.UI /// Result name. protected void SetResult( string resultName ) { - WebNavigator.NavigateTo( resultName, this ); + WebNavigator.NavigateTo( resultName, this, null ); } /// @@ -1146,7 +1152,7 @@ namespace Spring.Web.UI /// The context to use for evaluating the SpEL expression in the Result. protected void SetResult( string resultName, object context ) { - WebNavigator.NavigateTo( resultName, context ); + WebNavigator.NavigateTo( resultName, this, context ); } /// @@ -1158,7 +1164,7 @@ namespace Spring.Web.UI /// A redirect url string. protected string GetResultUrl( string resultName ) { - return ResolveUrl( WebNavigator.GetResultUri( resultName, this ) ); + return ResolveUrl( WebNavigator.GetResultUri( resultName, this, null ) ); } /// @@ -1171,7 +1177,7 @@ namespace Spring.Web.UI /// A redirect url string. protected string GetResultUrl( string resultName, object context ) { - return ResolveUrl( WebNavigator.GetResultUri( resultName, context ) ); + return ResolveUrl( WebNavigator.GetResultUri( resultName, this, context ) ); } #endregion diff --git a/src/Spring/Spring.Web/Web/UI/UserControl.cs b/src/Spring/Spring.Web/Web/UI/UserControl.cs index 764ac286..add41135 100644 --- a/src/Spring/Spring.Web/Web/UI/UserControl.cs +++ b/src/Spring/Spring.Web/Web/UI/UserControl.cs @@ -496,7 +496,7 @@ namespace Spring.Web.UI /// protected virtual void InitializeNavigationSupport() { - webNavigator = new WebFormsResultWebNavigator(this, null, true); + webNavigator = new WebFormsResultWebNavigator(this, null, null, true); } /// @@ -585,7 +585,7 @@ namespace Spring.Web.UI /// Result name. protected void SetResult( string resultName ) { - WebNavigator.NavigateTo( resultName, this ); + WebNavigator.NavigateTo( resultName, this, null ); } @@ -596,7 +596,7 @@ namespace Spring.Web.UI /// The context to use for evaluating the SpEL expression in the Result. protected void SetResult( string resultName, object context ) { - WebNavigator.NavigateTo( resultName, context ); + WebNavigator.NavigateTo( resultName, this, context ); } @@ -609,7 +609,7 @@ namespace Spring.Web.UI /// A redirect url string. protected string GetResultUrl( string resultName ) { - return ResolveUrl( WebNavigator.GetResultUri( resultName, this ) ); + return ResolveUrl( WebNavigator.GetResultUri( resultName, this, null ) ); } /// @@ -622,7 +622,7 @@ namespace Spring.Web.UI /// A redirect url string. protected string GetResultUrl( string resultName, object context ) { - return ResolveUrl( WebNavigator.GetResultUri( resultName, context ) ); + return ResolveUrl( WebNavigator.GetResultUri( resultName, this, context ) ); } #endregion diff --git a/test/Spring/Spring.Data.Tests/Dao/Attributes/PersistenceExceptionTranslationAdvisorTests.cs b/test/Spring/Spring.Data.Tests/Dao/Attributes/PersistenceExceptionTranslationAdvisorTests.cs index 08cd1663..6e156f74 100644 --- a/test/Spring/Spring.Data.Tests/Dao/Attributes/PersistenceExceptionTranslationAdvisorTests.cs +++ b/test/Spring/Spring.Data.Tests/Dao/Attributes/PersistenceExceptionTranslationAdvisorTests.cs @@ -126,7 +126,7 @@ namespace Spring.Dao.Attributes { //Expected Assert.AreSame(persistenceException, ex.InnerException); - } catch (PersistenceException ex) + } catch (PersistenceException) { Assert.Fail("Should have been translated"); } diff --git a/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2005.csproj b/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2005.csproj index cc126dab..c4717464 100644 --- a/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2005.csproj +++ b/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2005.csproj @@ -109,6 +109,7 @@ + Code diff --git a/test/Spring/Spring.Web.Tests/Web/UI/PageTests.cs b/test/Spring/Spring.Web.Tests/Web/UI/PageTests.cs index eb19ee5c..3bc85a14 100644 --- a/test/Spring/Spring.Web.Tests/Web/UI/PageTests.cs +++ b/test/Spring/Spring.Web.Tests/Web/UI/PageTests.cs @@ -97,7 +97,7 @@ namespace Spring.Web.UI } catch(ArgumentException ae) { - string expected = string.Format("No result mapping found for the specified name '{0}'.", RESULTNAME); + string expected = string.Format("No mapping found for the specified destination '{0}'.", RESULTNAME); string msg = ae.Message.Substring(0, expected.Length); Assert.AreEqual(expected, msg); } diff --git a/test/Spring/Spring.Web.Tests/Web/UI/UserControlTests.cs b/test/Spring/Spring.Web.Tests/Web/UI/UserControlTests.cs index fee74e3b..976855eb 100644 --- a/test/Spring/Spring.Web.Tests/Web/UI/UserControlTests.cs +++ b/test/Spring/Spring.Web.Tests/Web/UI/UserControlTests.cs @@ -105,8 +105,8 @@ namespace Spring.Web.UI using (mocks.Ordered()) { - // context is the control, that SetResult() was called on - theResult.Navigate(c111); + // context is the control, that contains matching Result + theResult.Navigate(c1); } mocks.ReplayAll();