Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv10254/src/Spring/Spring.Web/Web/UI
Modified Files:
Page.cs UserControl.cs
Log Message:
fixed SPRNET-531, SPRNET-864
Index: Page.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI/Page.cs,v
retrieving revision 1.85
retrieving revision 1.86
diff -C2 -d -r1.85 -r1.86
*** Page.cs 28 Nov 2007 23:26:10 -0000 1.85
--- Page.cs 2 Feb 2008 09:12:44 -0000 1.86
***************
*** 19,22 ****
--- 19,24 ----
#endregion
+ #region Imports
+
using System;
using System.Collections;
***************
*** 45,48 ****
--- 47,52 ----
using IValidator=Spring.Validation.IValidator;
+ #endregion
+
namespace Spring.Web.UI
{
***************
*** 1086,1090 ****
/// </summary>
/// <param name="resultName">Result name.</param>
! protected void SetResult(string resultName)
{
Result result = (Result) Results[resultName];
--- 1090,1094 ----
/// </summary>
/// <param name="resultName">Result name.</param>
! protected internal void SetResult(string resultName)
{
Result result = (Result) Results[resultName];
Index: UserControl.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/UI/UserControl.cs,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** UserControl.cs 23 Aug 2007 08:27:08 -0000 1.49
--- UserControl.cs 2 Feb 2008 09:12:44 -0000 1.50
***************
*** 19,22 ****
--- 19,24 ----
#endregion
+ #region Imports
+
using System;
using System.Collections;
***************
*** 34,37 ****
--- 36,40 ----
using Spring.Context;
using Spring.Context.Support;
+ using Spring.Core;
using Spring.DataBinding;
using Spring.Globalization;
***************
*** 39,42 ****
--- 42,47 ----
using Spring.Web.Support;
+ #endregion
+
namespace Spring.Web.UI
{
***************
*** 64,67 ****
--- 69,73 ----
private IDictionary sharedState;
private IBindingContainer bindingManager;
+ private IDictionary results;
private IApplicationContext applicationContext;
private IApplicationContext defaultApplicationContext;
***************
*** 388,391 ****
--- 394,469 ----
#endregion Shared State support
+ #region Result support
+
+ /// <summary>
+ /// Gets or sets map of result names to target URLs
+ /// </summary>
+ [Browsable(false)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ public IDictionary Results
+ {
+ get
+ {
+ if (results == null)
+ {
+ results = new Hashtable();
+ }
+ return results;
+ }
+ set
+ {
+ results = new Hashtable();
+ foreach (DictionaryEntry entry in value)
+ {
+ if (entry.Value is Result)
+ {
+ results[entry.Key] = entry.Value;
+ }
+ else if (entry.Value is String)
+ {
+ results[entry.Key] = new Result((string)entry.Value);
+ }
+ else
+ {
+ throw new TypeMismatchException(
+ "Unable to create result object. Please use either String or Result instances to define results.");
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Redirects user to a URL mapped to specified result name.
+ /// </summary>
+ /// <param name="resultName">Result name.</param>
+ protected void SetResult(string resultName)
+ {
+ Result result = (Result)Results[resultName];
+ if (result == null)
+ {
+ // bubble up result in the hierarchy
+ Control parent = this.Parent;
+ while(parent != null)
+ {
+ if (parent is UserControl)
+ {
+ ((UserControl)parent).SetResult(resultName);
+ return;
+ }
+ else if (parent is Page)
+ {
+ ((Page) parent).SetResult(resultName);
+ return;
+ }
+ parent = parent.Parent;
+ }
+ throw new ArgumentException(string.Format("No URL mapping found for the specified result '{0}'.", resultName), "resultName");
+ }
+
+ result.Navigate(this);
+ }
+
+ #endregion
+
#region Data binding support
|