Return-Path:
Delivered-To: apmail-struts-dev-archive@www.apache.org
Received: (qmail 86819 invoked from network); 21 Oct 2005 13:49:42 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199)
by minotaur.apache.org with SMTP; 21 Oct 2005 13:49:42 -0000
Received: (qmail 83850 invoked by uid 500); 21 Oct 2005 13:48:29 -0000
Delivered-To: apmail-struts-dev-archive@struts.apache.org
Received: (qmail 83795 invoked by uid 500); 21 Oct 2005 13:48:28 -0000
Mailing-List: contact dev-help@struts.apache.org; run by ezmlm
Precedence: bulk
List-Unsubscribe:
List-Help:
List-Post:
List-Id: "Struts Developers List"
Reply-To: "Struts Developers List"
Delivered-To: mailing list dev@struts.apache.org
Received: (qmail 83767 invoked by uid 500); 21 Oct 2005 13:48:28 -0000
Received: (qmail 83754 invoked by uid 99); 21 Oct 2005 13:48:28 -0000
Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Oct 2005 06:48:28 -0700
X-ASF-Spam-Status: No, hits=-9.4 required=10.0
tests=ALL_TRUSTED,NO_REAL_NAME
X-Spam-Check-By: apache.org
Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194)
by apache.org (qpsmtpd/0.29) with SMTP; Fri, 21 Oct 2005 06:48:26 -0700
Received: (qmail 85914 invoked by uid 65534); 21 Oct 2005 13:48:06 -0000
Message-ID: <20051021134806.85913.qmail@minotaur.apache.org>
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r327181 - in /struts/sandbox/trunk/overdrive/Nexus:
Core/Helpers/IViewHelper.cs Core/Helpers/ViewHelper.cs Web/AlertLabel.cs
Web/FindControl.ascx.cs Web/GridControl.ascx.cs Web/MessageLabel.cs
Web/ViewControl.ascx.cs Web/WebHelper.cs
Date: Fri, 21 Oct 2005 13:48:04 -0000
To: commits@struts.apache.org
From: husted@apache.org
X-Mailer: svnmailer-1.0.5
X-Virus-Checked: Checked by ClamAV on apache.org
X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N
Author: husted
Date: Fri Oct 21 06:47:54 2005
New Revision: 327181
URL: http://svn.apache.org/viewcvs?rev=327181&view=rev
Log:
OVR-23
* Add automatic binding for TextLabels
* Rename ErrorsText to AlertsText for consistency
* Add support methods for obtaining messages for an entity ID
* Rename View_Errors to View_Alerts for consistency
Modified:
struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs
struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs
struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs
struts/sandbox/trunk/overdrive/Nexus/Web/FindControl.ascx.cs
struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs
struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs
struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs
struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs
Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs?rev=327181&r1=327180&r2=327181&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/IViewHelper.cs Fri Oct 21 06:47:54 2005
@@ -88,6 +88,29 @@
IDictionary Alerts { get; }
///
+ /// Return the Alerts for the specifiied ID,
+ /// formatted for display by a UI control.
+ ///
+ ///
+ /// If messages are localized or customized,
+ /// the helper will return correct version for the user.
+ /// UI specific implementation may markup the errors as needed.
+ ///
+ ///
+ string AlertsFor(string id);
+
+ ///
+ /// Return the Alerts, including any Fault, formatted for display by a UI control.
+ ///
+ ///
+ /// If messages are localized or customized,
+ /// the helper will return correct version for the user.
+ /// UI specific implementation may markup the errors as needed.
+ ///
+ ///
+ string AlertsText { get; }
+
+ ///
/// Indicate if alerts are queued.
///
/// True if alerts are queued.
@@ -118,7 +141,16 @@
bool IsNominal { get; }
///
- /// Return the Alerts, including any Fault, formatted for display by a UI control.
+ /// Record a list of hint (or advisory) messages,
+ /// keyed by a field or other identifier,
+ /// or to a magic global key.
+ ///
+ ///
+ IDictionary Hints { get; }
+
+ ///
+ /// Return the Hints for the specifiied ID,
+ /// formatted for display by a UI control.
///
///
/// If messages are localized or customized,
@@ -126,15 +158,7 @@
/// UI specific implementation may markup the errors as needed.
///
///
- string ErrorsText { get; }
-
- ///
- /// Record a list of hint (or advisory) messages,
- /// keyed by a field or other identifier,
- /// or to a magic global key.
- ///
- ///
- IDictionary Hints { get; }
+ string HintsFor(string id);
///
/// Indicate if Hints are queued.
Modified: struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs?rev=327181&r1=327180&r2=327181&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Core/Helpers/ViewHelper.cs Fri Oct 21 06:47:54 2005
@@ -147,7 +147,11 @@
#region Messages (abstract)
- public abstract string ErrorsText { get; }
+ public abstract string AlertsFor(string id);
+
+ public abstract string AlertsText { get; }
+
+ public abstract string HintsFor(string id);
public abstract string HintsText { get; }
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs?rev=327181&r1=327180&r2=327181&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/AlertLabel.cs Fri Oct 21 06:47:54 2005
@@ -10,18 +10,22 @@
///
/// Default suffix for NameLabel IDs ["_alert"].
///
+ ///
public const string ALERT_SUFFIX = "_alert";
///
/// Set the defaults for this subclass.
///
+ ///
public AlertLabel()
{
Suffix = ALERT_SUFFIX;
Resource = false;
Required = false;
View_Hint = false;
+ EnableViewState = false;
}
+
}
}
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/FindControl.ascx.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/FindControl.ascx.cs?rev=327181&r1=327180&r2=327181&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/FindControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/FindControl.ascx.cs Fri Oct 21 06:47:54 2005
@@ -42,7 +42,7 @@
IViewHelper helper = Read(FindCommand);
if (!helper.IsNominal)
{
- Page_Error = helper;
+ Page_Alert = helper;
}
return helper.Criteria;
}
@@ -82,7 +82,7 @@
public virtual void Open()
{
IViewHelper helper = ExecuteBind(FindCommand);
- if (!helper.IsNominal) Page_Error = helper;
+ if (!helper.IsNominal) Page_Alert = helper;
}
public virtual void Open(IDictionary criteria)
@@ -90,7 +90,7 @@
IViewHelper helper = GetHelperFor(FindCommand);
helper.Read(criteria, true);
ExecuteBind(helper);
- if (!helper.IsNominal) Page_Error = helper;
+ if (!helper.IsNominal) Page_Alert = helper;
}
///
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs?rev=327181&r1=327180&r2=327181&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs Fri Oct 21 06:47:54 2005
@@ -549,7 +549,7 @@
bool okay = helper.IsNominal;
if (!okay)
{
- Page_Error = helper;
+ Page_Alert = helper;
}
return okay;
}
@@ -641,7 +641,7 @@
list_Insert = true;
list_ItemIndex = 0;
}
- else Page_Error = helper;
+ else Page_Alert = helper;
}
#endregion
@@ -688,7 +688,7 @@
okay = this.Open();
// ISSUE: Event? Page_Prompt = (List_Insert) ? msg_ADD_SUCCESS : msg_SAVE_SUCCESS;
}
- if (!okay) Page_Error = helper;
+ if (!okay) Page_Alert = helper;
}
private void list_Quit(object source, DataGridCommandEventArgs e)
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs?rev=327181&r1=327180&r2=327181&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/MessageLabel.cs Fri Oct 21 06:47:54 2005
@@ -1,4 +1,6 @@
+using System;
using System.Web.UI.WebControls;
+using Nexus.Core.Helpers;
namespace Nexus.Web
{
@@ -123,6 +125,34 @@
set { _View_Alert = value;}
}
- }
-
+ ///
+ /// Present a list of error mesasges.
+ ///
+ ///
+ protected IViewHelper Alerts
+ {
+ set
+ {
+ if (value != null)
+ {
+ Text = value.AlertsFor(EntryID);
+ }
+ }
+ }
+
+ ///
+ /// Provide a standard Event Handler for passing Alert messages.
+ ///
+ /// Event source
+ /// Runtime parameters
+ ///
+ public void View_Alert_Handler(object sender, EventArgs e)
+ {
+ ViewArgs v = e as ViewArgs;
+ if (v == null) throw new ArgumentException("ViewLabel.View_Alert_Handler: !(e is ViewArgs)");
+ IViewHelper helper = v.Helper;
+ if (helper != null) Alerts = helper;
+ else throw new ArgumentException("ViewLabel.View_Alert_Handler: (e.helper==null)");
+ }
+ }
}
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs?rev=327181&r1=327180&r2=327181&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs Fri Oct 21 06:47:54 2005
@@ -34,9 +34,9 @@
/// Psuedo property to generate an Error event encapsulating
/// our Helper property, containing the error.
///
- protected IViewHelper Page_Error
+ protected IViewHelper Page_Alert
{
- set { View_Error_Handler(this, new ViewArgs(value)); }
+ set { View_Alert_Handler(this, new ViewArgs(value)); }
}
#region String utilities
@@ -151,7 +151,7 @@
/// Control to test.
/// True if control is a NameLabel
///
- protected bool IsMessageLabel(Control control)
+ protected bool IsViewLabel(Control control)
{
return (control is MessageLabel);
}
@@ -327,6 +327,22 @@
return helper;
}
+ protected virtual void InitViewLabels()
+ {
+ foreach (Control t in Controls)
+ {
+ if (IsViewLabel(t))
+ {
+ MessageLabel x = (MessageLabel) t;
+ if (x.View_Alert)
+ {
+ View_Alert += new EventHandler(x.View_Alert_Handler);
+ }
+ continue;
+ }
+ }
+ }
+
private void BindControls(ControlCollection controls, IDictionary dictionary, string prefix, string list_suffix)
{
foreach (Control t in controls)
@@ -337,7 +353,7 @@
object v = dictionary[ToColumn(x.ID, prefix)];
if (v != null) x.Text = v.ToString();
}
- if (IsMessageLabel(t))
+ if (IsViewLabel(t))
{
MessageLabel x = (MessageLabel) t;
object v = dictionary[ToColumn(x.ID, prefix)];
@@ -560,7 +576,7 @@
{
foreach (Control t in controls)
{
- if (IsMessageLabel(t))
+ if (IsViewLabel(t))
{
MessageLabel x = (MessageLabel) t;
if (x.Resource) try
@@ -669,29 +685,29 @@
///
/// Signal when an error is exposed.
///
- public event EventHandler View_Error;
+ public event EventHandler View_Alert;
///
/// Pass an error to another control registered to received it.
///
/// This object
/// A ViewArgs instance with the IViewHelper containing the error messages(s).
- private void View_Error_Handler(object sender, EventArgs e)
+ private void View_Alert_Handler(object sender, EventArgs e)
{
- if (View_Error != null)
+ if (View_Alert != null)
{
- View_Error(sender, e);
+ View_Alert(sender, e);
}
}
///
- /// Initialize the control to use the stanard View_Error event handerl.
+ /// Initialize the control to use the standard View_Alert event handerl.
///
/// Control to register
///
protected void InitView(ViewControl c)
{
- c.View_Error += new EventHandler(View_Error_Handler);
+ c.View_Alert += new EventHandler(View_Alert_Handler); // Bubble event
c.Profile = Profile;
}
@@ -723,6 +739,7 @@
///
protected virtual void Page_Init()
{
+ InitViewLabels();
if (IsPostBack) return;
GetMessages();
}
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs?rev=327181&r1=327180&r2=327181&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs Fri Oct 21 06:47:54 2005
@@ -6,9 +6,32 @@
{
public class WebHelper : ViewHelper
{
- public override string ErrorsText
+ public override string AlertsFor(string id)
{
- get { return HtmlMessageBuilder(Alerts); }
+ string alert = null;
+ IList list = Alerts[id] as IList;
+ if (list==null) return alert;
+
+ if (list.Count==1)
+ {
+ alert = HtmlMessage(list[0]);
+ }
+ else
+ {
+ alert = HtmlMessageList(list);
+ }
+ return alert;
+ }
+
+ public override string AlertsText
+ {
+ get
+ { return HtmlMessageBuilder(Alerts); }
+ }
+
+ public override string HintsFor(string id)
+ {
+ return HtmlMessageList(Hints[id] as IList);
}
public override string HintsText
@@ -17,6 +40,20 @@
}
#region Message utilities
+
+ ///
+ /// Build a message using HTML markup.
+ ///
+ /// A message
+ /// HTML markup presenting the messages.
+ ///
+ private string HtmlMessage(object message)
+ {
+ StringBuilder sb = new StringBuilder("");
+ sb.Append(message.ToString());
+ sb.Append("
");
+ return sb.ToString();
+ }
///
/// Build a set of messages using HTML markup.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org