You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2005/09/10 21:05:02 UTC
svn commit: r280025 [5/5] - in /struts/sandbox/trunk/overdrive/Nexus: Core/
Core/Helpers/ Extras/ Extras/Spring/ Test/ Test/Resources/Command/
Test/bin/Debug/ Web/
Added: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/log4net.dll
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/log4net.dll?rev=280025&view=auto
==============================================================================
Binary file - no diff available.
Propchange: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/log4net.dll
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx?rev=280025&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx Sat Sep 10 12:04:14 2005
@@ -0,0 +1 @@
+<%@ Control Language="c#" AutoEventWireup="false" Codebehind="GridControl.ascx.cs" Inherits="Nexus.Web.Controls.GridControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
Added: 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=280025&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs Sat Sep 10 12:04:14 2005
@@ -0,0 +1,658 @@
+using System;
+using System.Collections;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using Nexus.Core;
+using Nexus.Core.Helpers;
+
+namespace Nexus.Web.Controls
+{
+ public class GridControl : ViewControl
+ {
+ #region Runtime state Properties
+
+ /// <summary>
+ /// Attribute token for List_Criteria.
+ /// </summary>
+ private string LIST_CRITERIA_KEY = "list_Criteria";
+
+ /// <summary>
+ /// Values to use with a query statement.
+ /// </summary>
+ public virtual IDictionary list_Criteria
+ {
+ get
+ {
+ IDictionary criteria = ViewState[LIST_CRITERIA_KEY] as IDictionary;
+ return criteria;
+ }
+ set { ViewState[LIST_CRITERIA_KEY] = value; }
+ }
+
+ /// <summary>
+ /// Attribute token for List_ItemIndex
+ /// </summary>
+ private const string LIST_ITEM_INDEX = "list_ItemIndex";
+
+ /// <summary>
+ /// Current item index, used mainly to signal editing.
+ /// </summary>
+ public virtual int list_ItemIndex
+ {
+ get
+ {
+ object value = ViewState[LIST_ITEM_INDEX];
+ if (value == null) return -1;
+ return (int) value;
+ }
+ set
+ {
+ ViewState[LIST_ITEM_INDEX] = value;
+ if (Grid != null) Grid.EditItemIndex = value;
+ }
+ }
+
+ /// <summary>
+ /// Attribute token for List_ItemKey.
+ /// </summary>
+ private const string LIST_ITEM_KEY = "list_ItemKey";
+
+ /// <summary>
+ /// The data key for the selected item.
+ /// </summary>
+ public virtual string list_ItemKey
+ {
+ get { return ViewState[LIST_ITEM_KEY] as string; }
+ set { ViewState[LIST_ITEM_KEY] = value; }
+ }
+
+ /// <summary>
+ /// Attribute token for List_Insert.
+ /// </summary>
+ private const string LIST_INSERT_KEY = "list_Insert";
+
+ /// <summary>
+ /// Insert mode - are we adding or modifying?
+ /// </summary>
+ public virtual bool list_Insert
+ {
+ get
+ {
+ object value = ViewState[LIST_INSERT_KEY];
+ if (value == null) return false;
+ return (bool) value;
+ }
+ set { ViewState[LIST_INSERT_KEY] = value; }
+ }
+
+ private bool _HasCriteria = true;
+
+ public virtual bool HasCriteria
+ {
+ get { return _HasCriteria; }
+ set { _HasCriteria = value; }
+ }
+
+ #endregion
+
+ #region Command properties to set
+
+ private string _FindCommand;
+
+ public virtual string FindCommand
+ {
+ get { return _FindCommand; }
+ set { _FindCommand = value; }
+ }
+
+ private string _ListCommand;
+
+ public virtual string ListCommand
+ {
+ get { return _ListCommand; }
+ set { _ListCommand = value; }
+ }
+
+ private string _SaveCommand;
+
+ public virtual string SaveCommand
+ {
+ get { return _SaveCommand; }
+ set { _SaveCommand = value; }
+ }
+
+ #endregion
+
+ #region Column properties to set
+
+ private string _DataKeyField;
+
+ public virtual string DataKeyField
+ {
+ get { return _DataKeyField; }
+ set { _DataKeyField = value; }
+ }
+
+ private IList _DataFields;
+
+ public virtual IList DataFields
+ {
+ get { return _DataFields; }
+ set { _DataFields = value; }
+ }
+
+ private IList _DataLabels;
+
+ public virtual IList DataLabels
+ {
+ get { return _DataLabels; }
+ set { _DataLabels = value; }
+ }
+
+ #endregion
+
+ #region Column properties with defaults
+
+ public const string msg_EDIT_TEXT = "EDIT";
+ public const string msg_QUIT_TEXT = "CANCEL";
+ public const string msg_SAVE_TEXT = "SAVE";
+ public const string msg_ITEM_TEXT = "#";
+ public const string msg_ITEM_COMMAND = "Item";
+
+ private string _EditText = msg_EDIT_TEXT;
+
+ public virtual string EditText
+ {
+ get { return _EditText; }
+ set { _EditText = value; }
+ }
+
+ private string _QuitText = msg_QUIT_TEXT;
+
+ public virtual string QuitText
+ {
+ get { return _QuitText; }
+ set { _QuitText = value; }
+ }
+
+ private string _SaveText = msg_SAVE_TEXT;
+
+ public virtual string SaveText
+ {
+ get { return _SaveText; }
+ set { _SaveText = value; }
+ }
+
+ private string _ItemText = msg_ITEM_TEXT;
+
+ public virtual string ItemText
+ {
+ get { return _ItemText; }
+ set { _ItemText = value; }
+ }
+
+ private string _ItemCommand = msg_ITEM_COMMAND;
+
+ public virtual string ItemCommandName
+ {
+ get { return _ItemCommand as string; }
+ set { _ItemCommand = value; }
+ }
+
+ private bool _HasItemColumn = false;
+
+ public virtual bool HasItemColumn
+ {
+ get { return _HasItemColumn; }
+ set { _HasItemColumn = value; }
+ }
+
+ public virtual bool HasEditColumn
+ {
+ get { return (SaveCommand != null); }
+ set { throw new NotImplementedException(); }
+ }
+
+ #endregion
+
+ #region Binding methods
+
+ public virtual void DataSource(IViewHelper helper)
+ {
+ IList list = helper.Outcome as IList;
+ Grid.DataSource = list;
+ }
+
+ public virtual void DataBind()
+ {
+ Grid.DataBind();
+ }
+
+ public virtual int BindItemColumn(int i)
+ {
+ ButtonColumn column = new ButtonColumn();
+ column.ButtonType = ButtonColumnType.PushButton;
+ column.Text = ItemText;
+ column.CommandName = ItemCommandName;
+ Grid.Columns.AddAt(i, column);
+ return ++i;
+ }
+
+ public virtual int BindEditColumn(int i)
+ {
+ EditCommandColumn column = new EditCommandColumn();
+ column.ButtonType = ButtonColumnType.PushButton;
+ column.EditText = EditText;
+ column.CancelText = QuitText;
+ column.UpdateText = SaveText;
+ Grid.Columns.AddAt(i, column);
+ return ++i;
+ }
+
+ public virtual int BindColumns(int i)
+ {
+ DataGrid grid = Grid;
+ grid.DataKeyField = DataKeyField;
+ int colCount = DataFields.Count;
+ int lblCount = DataLabels.Count;
+ for (int c = 0; c < colCount; c++)
+ {
+ string column = DataFields[c] as string;
+ string label = (lblCount < c) ? column : DataLabels[c] as string;
+ i = BindColumn(i, label, column);
+ }
+ return i;
+ }
+
+ public int BindColumn(int pos, string headerText, string dataField, string sortExpression, string dataFormat)
+ {
+ BoundColumn column = new BoundColumn();
+ column.HeaderText = headerText;
+ column.DataField = dataField;
+ column.SortExpression = sortExpression; // See DataGridColumn.SortExpression Property
+ column.DataFormatString = dataFormat; // See Formatting Types in .NET Dev Guide
+ Grid.Columns.AddAt(pos, column);
+ return pos + 1;
+ }
+
+ public int BindColumn(int pos, string headerText, string dataField)
+ {
+ return BindColumn(pos, headerText, dataField, String.Empty, String.Empty);
+ }
+
+ private bool bind = true;
+
+ public virtual void InitGrid()
+ {
+ bind = true;
+ }
+
+ public virtual void BindGrid(IViewHelper helper)
+ {
+ // Only bind columns once
+ // WARNING: Won't work with a singleton
+ if (bind)
+ {
+ bind = false;
+ int i = 0;
+ if (HasEditColumn) i = BindEditColumn(i);
+ if (HasItemColumn) i = BindItemColumn(i);
+ BindColumns(i);
+
+ }
+ DataSource(helper);
+ DataBind();
+ }
+
+ #endregion
+
+ #region Command methods
+
+ /// <summary>
+ /// If "Add Row" feature is going to be used,
+ /// Override getter to return new instance of the Context list
+ /// for this application.
+ /// </summary>
+ public virtual IEntryList NewContextList
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public virtual IViewHelper DataInsert()
+ {
+ DataGrid grid = Grid;
+ IEntryList list = NewContextList;
+ // Fake a blank row
+ IViewHelper helper = GetHelperFor(ListCommand);
+ list.Insert(String.Empty);
+ // ISSUE: FIXME: Do we need helper.Outcome = list;
+ grid.DataSource = list;
+ grid.CurrentPageIndex = 0;
+ grid.EditItemIndex = 0;
+ DataBind();
+ return helper;
+ }
+
+ public virtual IViewHelper Find(string key, ControlCollection controls)
+ {
+ IViewHelper helper = ExecuteBind(FindCommand);
+ return helper;
+ }
+
+ public virtual IViewHelper Save(string key, ControlCollection controls)
+ {
+ IViewHelper h = GetHelperFor(SaveCommand);
+ if (h.IsNominal)
+ {
+ h.Criteria[DataKeyField] = key;
+ int cols = DataFields.Count;
+ string[] keys = new string[2 + cols];
+ // reconstruct the standard edit column keys
+ // just as placeholders, really
+ keys[0] = SaveText;
+ keys[1] = QuitText;
+ int index = 2;
+ // append our field names to the array of keys
+ for (int i = 0; i < cols; i++)
+ keys[index++] = DataFields[i] as string;
+ ReadControls(h.Criteria, keys, true);
+ h.Execute();
+ }
+ return h;
+ }
+
+ #endregion
+
+ #region Loading methods
+
+ public virtual IViewHelper ExecuteList()
+ {
+ IViewHelper helper = Execute(ListCommand);
+ bool okay = helper.IsNominal;
+ if (okay) BindGrid(helper);
+ return helper;
+ }
+
+ public virtual IViewHelper ExecuteList(IDictionary criteria)
+ {
+ IViewHelper helper = GetHelperFor(ListCommand);
+ helper.ReadExecute(criteria);
+ bool okay = helper.IsNominal;
+ if (okay) BindGrid(helper);
+ return helper;
+ }
+
+ public virtual IViewHelper LoadGrid(IDictionary criteria)
+ {
+ IViewHelper helper;
+ if (HasCriteria)
+ helper = ExecuteList(criteria);
+ else
+ helper = ExecuteList();
+ return helper;
+ }
+
+ #endregion
+
+ #region List properties to set
+
+ private DataGrid _Grid;
+
+ public DataGrid Grid
+ {
+ get { return _Grid; }
+ set { _Grid = value; }
+ }
+
+ #endregion
+
+ #region List methods
+
+ public virtual bool Open()
+ {
+ IViewHelper helper = this.LoadGrid(list_Criteria);
+ bool okay = helper.IsNominal;
+ if (!okay)
+ {
+ Page_Error = helper;
+ }
+ return okay;
+ }
+
+ protected virtual void list_Item(string commandName, int index)
+ {
+ switch (commandName)
+ {
+ case "Page":
+ // Handled by StepList_PageIndexChanged
+ break;
+ case msg_ITEM_COMMAND:
+ list_Item_Click(index);
+ break;
+ default:
+ {
+ if (list_Insert)
+ // ISSUE: If insert fails, old input is not retained. [WNE-67]
+ list_Add_Load();
+ else
+ list_Refresh();
+ break;
+ }
+ }
+ }
+
+ protected virtual void list_Edit(int index)
+ {
+ // ISSUE: Event? Page_Prompt = msg_EDIT_HINT;
+ list_ItemIndex = index;
+ list_Refresh();
+ }
+
+ protected virtual void list_Quit()
+ {
+ // ISSUE: Event? Page_Prompt = msg_QUIT_SUCCESS;
+ list_Insert = false;
+ list_ItemIndex = -1;
+ list_Refresh();
+ }
+
+ protected virtual void list_Refresh()
+ {
+ DataBind();
+ }
+
+ protected virtual void list_Add_Load()
+ {
+ IViewHelper helper = DataInsert();
+ bool okay = helper.IsNominal;
+ if (okay)
+ {
+ // ISSUE: Event? Page_Prompt = msg_EDIT_HINT;
+ list_Insert = true;
+ list_ItemIndex = 0;
+ }
+ else Page_Error = helper;
+ }
+
+ #endregion
+
+ #region List events
+
+ private string GetDataKey ()
+ {
+ DataGrid grid = Grid;
+ int index = grid.EditItemIndex;
+ string key = grid.DataKeys [index] as string;
+ return key;
+ }
+
+ private ControlCollection GetControls (DataGridCommandEventArgs e)
+ {
+ DataGrid grid = Grid;
+ ControlCollection controls = new ControlCollection (grid);
+ foreach (TableCell t in e.Item.Cells)
+ {
+ for (int i = 0; i < t.Controls.Count; i++)
+ controls.Add (t.Controls [i]);
+ }
+ return controls;
+ }
+
+ private bool GetList ()
+ {
+ IViewHelper helper = Execute (ListCommand);
+ bool okay = helper.IsNominal;
+ if (okay)
+ {
+ DataSource (helper);
+ DataBind ();
+ }
+ return okay;
+ }
+
+ // postback events
+
+ protected void list_Edit(object source, DataGridCommandEventArgs e)
+ {
+ list_Edit(e.Item.ItemIndex);
+ }
+
+ protected void list_Save(object source, DataGridCommandEventArgs e)
+ {
+ string key = (list_Insert) ? null : GetDataKey();
+ ControlCollection controls = GetControls(e);
+ IViewHelper helper = Save(key, controls);
+ bool okay = helper.IsNominal;
+ if (okay)
+ {
+ okay = GetList();
+ // ISSUE: Event? Page_Prompt = (List_Insert) ? msg_ADD_SUCCESS : msg_SAVE_SUCCESS;
+ list_Insert = false;
+ list_ItemIndex = -1;
+ list_Refresh();
+ }
+ // ISSUE: Event? if (!okay) Page_Error = Helper;
+ }
+
+ protected void list_Quit(object source, DataGridCommandEventArgs e)
+ {
+ list_Quit();
+ }
+
+ protected virtual void list_Add(object sender, EventArgs e)
+ {
+ list_Add_Load();
+ }
+
+ protected void List_Item(object source, DataGridCommandEventArgs e)
+ {
+ int index = e.Item.ItemIndex;
+ list_Item(e.CommandName, index);
+ }
+
+ protected void list_PageIndexChanged(object sender, DataGridPageChangedEventArgs e)
+ {
+ Grid.CurrentPageIndex = e.NewPageIndex;
+ list_Refresh();
+ }
+
+ #endregion
+
+ public void list_Item_Click(int index)
+ {
+ //
+ }
+
+ private void Page_Load(object sender, EventArgs e)
+ {
+ Grid.AutoGenerateColumns = false;
+ Grid.EditItemIndex = list_ItemIndex;
+ Grid.CancelCommand += new DataGridCommandEventHandler(list_Quit);
+ Grid.EditCommand += new DataGridCommandEventHandler(list_Edit);
+ Grid.UpdateCommand += new DataGridCommandEventHandler(list_Save);
+ Grid.ItemCommand += new DataGridCommandEventHandler(List_Item);
+ Grid.PageIndexChanged += new DataGridPageChangedEventHandler(list_PageIndexChanged);
+ if (this.Visible) Open();
+ }
+
+ #region Web Form Designer generated code
+
+ protected override void OnInit(EventArgs e)
+ {
+ //
+ // CODEGEN: This call is required by the ASP.NET Web Form Designer.
+ //
+ InitializeComponent();
+ base.OnInit(e);
+ InitGrid();
+ }
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.Load += new EventHandler(this.Page_Load);
+ }
+
+ #endregion
+ }
+
+
+ /*
+
+
+ #region List Panel
+
+ protected Panel pnlList;
+ protected DataGridControl list_report;
+ // from BaseGrid: Button cmdListAdd;
+
+ private void List_Init()
+ {
+ list_report.Helper = this.Helper;
+ list_report.List_Init();
+ pnlList.Visible = false;
+ }
+
+ /// <summary>
+ /// Select only those items in control
+ /// whose Value property matches the given value.
+ /// If the value is null, no action is taken.
+ /// </summary>
+ /// <param name="control">ListControl to process</param>
+ /// <param name="text">Text label to match</param>
+ ///
+ static void SelectItemText (ListControl control, string text)
+ {
+ if (text != null)
+ {
+ foreach (ListItem i in control.Items)
+ i.Selected = false;
+
+ foreach (ListItem i in control.Items)
+ {
+ if (text.Equals (i.Text))
+ i.Selected = true;
+ }
+ }
+ }
+
+ private void List_Edit_Submit(IDictionary context)
+ {
+ Helper.BindControls(pnlEdit.Controls,context,null);
+ string county_name = context[App.COUNTY_NAME] as string;
+ SelectItemText(county_key_list,county_name);
+ Template_Load (App.msg_ROUTING_HEADING, App.msg_ROUTING_EDIT_PROMPT);
+ pnlEdit.Visible = true;
+ pnlFind.Visible = false;
+ pnlList.Visible = false;
+ }
+
+ #endregion
+
+
+
+ */
+}
\ No newline at end of file
Added: struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.resx
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.resx?rev=280025&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.resx (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.resx Sat Sep 10 12:04:14 2005
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<root>
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="ResMimeType">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="Version">
+ <value>1.0.0.0</value>
+ </resheader>
+ <resheader name="Reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="Writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
Added: struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx?rev=280025&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx Sat Sep 10 12:04:14 2005
@@ -0,0 +1 @@
+<%@ Control Language="c#" AutoEventWireup="false" Codebehind="ViewControl.ascx.cs" Inherits="Nexus.Web.Controls.ViewControl" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
Added: 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=280025&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs Sat Sep 10 12:04:14 2005
@@ -0,0 +1,577 @@
+using System;
+using System.Collections;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using Nexus.Core;
+using Nexus.Core.Helpers;
+using UserControl = Spring.Web.UI.UserControl;
+
+namespace Nexus.Web.Controls
+{
+ /// <summary>
+ /// Base class for view controls (sub forms).
+ /// </summary>
+ public class ViewControl : UserControl
+ {
+ private string _TitleText;
+ public virtual string TitleText
+ {
+ get { return _TitleText; }
+ set { _TitleText = value; }
+ }
+
+ private string _HeadingText;
+ public virtual string HeadingText
+ {
+ get { return _HeadingText; }
+ set { _HeadingText = value; }
+ }
+
+ private string _PromptText;
+ public virtual string PromptText
+ {
+ get { return _PromptText; }
+ set { _PromptText = value; }
+ }
+
+ private IRequestCatalog _Catalog;
+
+ /// <summary>
+ /// Helper passed by an enclosing control (e.g. Page).
+ /// </summary>
+ /// <remarks><p>
+ /// Subclasses adding EventHandlers
+ /// should pass a reference to themselves with a ViewArgs instance,
+ /// encapsulating the Helper.
+ /// </p></remarks>
+ public virtual IRequestCatalog Catalog
+ {
+ get { return _Catalog; }
+ set { _Catalog = value; }
+ }
+
+ /// <summary>
+ /// Psuedo property to generate an Error event encapsulating
+ /// our Helper property, containing the error.
+ /// </summary>
+ protected IViewHelper Page_Error
+ {
+ set { View_Error_Send(this, new ViewArgs(value)); }
+ }
+
+ #region Control utilities
+
+ #region String utilities
+
+ private string NullIfEmpty(string input)
+ {
+ return (string.Empty.Equals(input)) ? null : input;
+ }
+
+ /// <summary>
+ /// Extract the root name from the id, allowing for a prefix and suffix.
+ /// </summary>
+ /// <param name="id">The full id, including prefix and suffix.</param>
+ /// <param name="prefix">The prefix to omit.</param>
+ /// <param name="suffix">The suffix to omit.</param>
+ /// <returns></returns>
+ private string RootId(string id, string prefix, string suffix)
+ {
+ int v = id.LastIndexOf(suffix);
+ string fore = id.Substring(0, v);
+ string root = ToColumn(fore, prefix);
+ return root;
+ }
+
+ /// <summary>
+ /// Trim Sany QL wildcards that may have been added to a search string.
+ /// </summary>
+ /// <param name="input">String to trim</param>
+ /// <returns>Input without SQL wildcards</returns>
+ protected string TrimWildCards(string input)
+ {
+ string trimmed = null;
+ if (input!=null) trimmed = input.Trim('%');
+ return trimmed;
+ }
+
+ private static KeyValue _NullKey = new KeyValue(String.Empty, "--v--");
+
+ /// <summary>
+ /// Default value for dropdown lists.
+ /// </summary>
+ protected KeyValue NullKey
+ {
+ get { return _NullKey; }
+ }
+
+ /// <summary>
+ /// The default list suffix.
+ /// </summary>
+ private string _ListSuffix = "_list";
+
+ protected string ListSuffix
+ {
+ get { return _ListSuffix; }
+ set { _ListSuffix = value; }
+ }
+
+ #endregion
+
+ /// <summary>
+ /// Return true if control is a Label.
+ /// </summary>
+ /// <param name="control">Control to test.</param>
+ /// <returns>True if control is a Label</returns>
+ ///
+ protected bool IsLabel(Control control)
+ {
+ return (typeof (Label).Equals(control.GetType()));
+ }
+
+ /// <summary>
+ /// Return true if control is a TextBox.
+ /// </summary>
+ /// <param name="control">Control to test.</param>
+ /// <returns>True if control is a TextBox</returns>
+ ///
+ protected bool IsTextBox(Control control)
+ {
+ return (typeof (TextBox).Equals(control.GetType()));
+ }
+
+ /// <summary>
+ /// Return true if control is a List Control or one of the standard subclasses.
+ /// </summary>
+ /// <param name="control">Control to test.</param>
+ /// <returns>True if control is a TextBox</returns>
+ ///
+ protected bool IsListControl(Control control)
+ {
+ bool isList = false;
+ Type type = control.GetType();
+ isList = (isList) || typeof (ListControl).Equals(type);
+ isList = (isList) || typeof (CheckBoxList).Equals(type);
+ isList = (isList) || typeof (DropDownList).Equals(type);
+ isList = (isList) || typeof (ListBox).Equals(type);
+ isList = (isList) || typeof (RadioButtonList).Equals(type);
+ return isList;
+ }
+
+ /// <summary>
+ /// Return true if control is a Checkbox.
+ /// </summary>
+ /// <param name="control">Control to test.</param>
+ /// <returns>True if control is a Checkbox</returns>
+ ///
+ protected bool IsCheckBox(Control control)
+ {
+ return (typeof (CheckBox).Equals(control.GetType()));
+ }
+
+ /// <summary>
+ /// Return true if control is a RadioButton.
+ /// </summary>
+ /// <param name="control">Control to test.</param>
+ /// <returns>True if control is a RadioButton</returns>
+ ///
+ protected bool IsRadioButton(Control control)
+ {
+ return (typeof (RadioButton).Equals(control.GetType()));
+ }
+
+ /// <summary>
+ /// Select only those items in control
+ /// whose Text property matches the given text.
+ /// If the value is null, no action is taken.
+ /// </summary>
+ /// <param name="control">Control to set</param>
+ /// <param name="text">Text to match</param>
+ ///
+ protected void SelectItemText(ListControl control, string text)
+ {
+ if (text != null)
+ {
+ foreach (ListItem i in control.Items)
+ i.Selected = false;
+
+ foreach (ListItem i in control.Items)
+ {
+ if (text.Equals(i.Text))
+ i.Selected = true;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Set Labels and TextBoxes to an empty string
+ /// to ensure inappropriate values are not carried over.
+ /// </summary>
+ ///
+ protected void ResetControls()
+ {
+
+ ControlCollection controls = this.Controls;
+ foreach (Control control in controls)
+ {
+ if (IsLabel(control))
+ {
+ Label x = (Label) control;
+ x.Text = String.Empty;
+ }
+ if (IsTextBox(control))
+ {
+ TextBox x = (TextBox) control;
+ x.Text = String.Empty;
+ }
+ if (IsListControl(control))
+ {
+ ListControl x = (ListControl) control;
+ x.SelectedIndex = -1;
+ }
+ }
+ }
+
+ protected IViewHelper GetHelperFor(string command)
+ {
+ IViewHelper helper = Catalog.GetHelperFor(command);
+ return helper;
+ }
+
+ protected IViewHelper Execute(string command)
+ {
+ IViewHelper helper = GetHelperFor(command);
+ helper.Execute();
+ return helper;
+ }
+
+ protected void BindControls(IDictionary dictionary, string prefix, string list_suffix)
+ {
+ ControlCollection controls = this.Controls;
+ foreach (Control t in controls)
+ {
+ if (IsTextBox(t))
+ {
+ TextBox x = (TextBox) t;
+ object v = dictionary[ToColumn(x.ID, prefix)];
+ if (v != null) x.Text = v.ToString();
+ }
+ if (IsLabel(t))
+ {
+ Label x = (Label) t;
+ object v = dictionary[ToColumn(x.ID, prefix)];
+ if (v != null) x.Text = v.ToString();
+ }
+ if (IsListControl(t))
+ {
+ ListControl x = (ListControl) t;
+ string root = RootId(x.ID, prefix, list_suffix);
+ IList s = dictionary[root + list_suffix] as IList; // this_key_list
+ string r = dictionary[root] as string; // this_key
+ if ((null == r) || (0 == r.Length))
+ BindListControl(x, s);
+ else
+ BindListControl(x, s, r);
+ }
+ }
+ }
+
+ protected void BindControls(IDictionary dictionary, string prefix)
+ {
+ BindControls(dictionary, prefix, ListSuffix);
+ }
+
+ protected void BindControls(IDictionary dictionary)
+ {
+ BindControls(dictionary, null, ListSuffix);
+ }
+
+ protected IViewHelper ExecuteBind(string command)
+ {
+ IViewHelper helper = GetHelperFor(command);
+ helper.Execute();
+ BindControls(helper.Criteria);
+ return helper;
+ }
+
+ protected void ExecuteBind(IViewHelper helper)
+ {
+ helper.Execute();
+ BindControls(helper.Criteria);
+ if (helper.IsNominal) helper.Execute();
+ }
+
+ /// <summary>
+ /// Render a control id as a column name
+ /// by trimming a prefix from the id, if any.
+ /// </summary>
+ /// <param name="id">String to process.</param>
+ /// <param name="prefix">Prefix to remove.</param>
+ /// <returns>id without prefix.</returns>
+ ///
+ private string ToColumn(string id, string prefix)
+ {
+ string trimmed;
+ if (null == prefix) trimmed = id;
+ else trimmed = id.Substring(prefix.Length);
+ return trimmed;
+ }
+
+
+ protected void ReadControls(IDictionary dictionary, string[] keys, bool nullIfEmpty)
+ {
+ ControlCollection controls = this.Controls;
+ int i = 0;
+ foreach (Control t in controls)
+ {
+ string key = keys[i];
+ if (IsTextBox(t))
+ {
+ TextBox x = (TextBox) t;
+ string value = (nullIfEmpty) ? NullIfEmpty(x.Text) : x.Text;
+ dictionary.Add(key, value);
+ }
+ if (IsLabel(t))
+ {
+ Label x = (Label) t;
+ string value = (nullIfEmpty) ? NullIfEmpty(x.Text) : x.Text;
+ dictionary.Add(key, value);
+ }
+ if (IsListControl(t))
+ {
+ ListControl x = (ListControl) t;
+ string value = (nullIfEmpty) ? NullIfEmpty(x.SelectedValue) : x.SelectedValue;
+ dictionary.Add(key, value);
+ }
+ if (IsCheckBox(t))
+ {
+ CheckBox x = (CheckBox) t;
+ string value = (x.Checked) ? key : null;
+ dictionary.Add(key, value);
+ }
+ if (IsRadioButton(t))
+ {
+ RadioButton x = (RadioButton) t;
+ string value = (x.Checked) ? key : null;
+ dictionary.Add(key, value);
+ }
+ i++;
+ }
+ }
+
+ protected void ReadControls(IDictionary dictionary, string prefix, string list_suffix, bool nullIfEmpty)
+ {
+ ControlCollection controls = this.Controls;
+ foreach (Control t in controls)
+ {
+ if (IsTextBox(t))
+ {
+ TextBox x = (TextBox) t;
+ string value = (nullIfEmpty) ? NullIfEmpty(x.Text) : x.Text;
+ dictionary.Add(ToColumn(x.ID, prefix), value);
+ }
+ if (IsLabel(t))
+ {
+ Label x = (Label) t;
+ string value = (nullIfEmpty) ? NullIfEmpty(x.Text) : x.Text;
+ dictionary.Add(ToColumn(x.ID, prefix), value);
+ }
+ if (IsListControl(t))
+ {
+ ListControl x = (ListControl) t;
+ string root = RootId(x.ID, prefix, list_suffix);
+ string value = (nullIfEmpty) ? NullIfEmpty(x.SelectedValue) : x.SelectedValue;
+ dictionary.Add(root, value);
+ }
+ if (IsCheckBox(t))
+ {
+ CheckBox x = (CheckBox) t;
+ string key = ToColumn(x.ID, prefix);
+ string value = (x.Checked) ? key : null;
+ dictionary.Add(key, value);
+ }
+ if (IsRadioButton(t))
+ {
+ RadioButton x = (RadioButton) t;
+ string key = ToColumn(x.ID, prefix);
+ string value = (x.Checked) ? key : null;
+ dictionary.Add(key, value);
+ }
+ }
+ }
+
+ protected void ReadControls(IDictionary dictionary, bool nullIfEmpty)
+ {
+ ReadControls(dictionary,null,ListSuffix,nullIfEmpty);
+ }
+
+ protected IViewHelper Read(string command, bool nullIfEmpty)
+ {
+ IViewHelper helper = GetHelperFor(command);
+ ReadControls(helper.Criteria,nullIfEmpty);
+ return helper;
+ }
+
+ protected IViewHelper Read(string command)
+ {
+ return Read(command,true);
+ }
+
+ protected IViewHelper ReadExecute(string command, bool nullIfEmpty)
+ {
+ IViewHelper helper = Read(command,nullIfEmpty);
+ helper.Execute();
+ return helper;
+ }
+
+ protected IViewHelper ReadExecute(string command)
+ {
+ return ReadExecute(command,true);
+ }
+
+ protected IViewHelper Read(string command, IDictionary criteria, bool nullIfEmpty)
+ {
+ IViewHelper helper = GetHelperFor(command);
+ helper.Read(criteria,nullIfEmpty);
+ return helper;
+ }
+
+ protected IViewHelper ReadExecute(string command, IDictionary criteria, bool nullIfEmpty)
+ {
+ IViewHelper helper = Read(command, criteria, nullIfEmpty);
+ helper.Execute();
+ return helper;
+ }
+
+ protected IViewHelper ReadExecute(string command, IDictionary criteria)
+ {
+ return ReadExecute(command,criteria,true);
+ }
+
+
+ #region ListControl methods
+
+ /// <summary>
+ /// Select only those items in control
+ /// whose Value property matches the given value.
+ /// If the value is null, no action is taken.
+ /// </summary>
+ /// <param name="control"></param>
+ /// <param name="value"></param>
+ ///
+ protected void SelectItem(ListControl control, string value)
+ {
+ if (value != null)
+ {
+ foreach (ListItem i in control.Items)
+ i.Selected = false;
+
+ foreach (ListItem i in control.Items)
+ {
+ if (value.Equals(i.Value))
+ i.Selected = true;
+ }
+ }
+ }
+
+ /// <summary>
+ /// Deactivate the selected item, and select any item matching value.
+ /// </summary>
+ /// <param name="control"></param>
+ /// <param name="value"></param>
+ ///
+ protected void SelectListItem(ListControl control, string value)
+ {
+ try
+ {
+ control.SelectedIndex = -1;
+ SelectItem(control, value);
+ }
+ catch (NullReferenceException e1)
+ {
+ if (e1 == null) value = string.Empty; // placate the IDE
+ }
+ }
+
+ /// <summary>
+ /// Bind a list of KeyValue objects to a ListControl,
+ /// select any item matching value.
+ /// </summary>
+ /// <param name="control">ListControl to process</param>
+ /// <param name="list">List of TextKey objects.</param>
+ /// <param name="value">Value to select, or null if nothing is selected.</param>
+ ///
+ private void BindListControl(ListControl control, IList list, string value)
+ {
+ control.DataTextField = "Value";
+ control.DataValueField = "Key";
+ control.DataSource = list;
+ control.DataBind();
+ SelectListItem(control, value);
+ }
+
+ protected void BindListControl(ListControl control, IList list)
+ {
+ bool insertKey = ((list != null) && (!list.Contains(NullKey)));
+ if (insertKey) list.Insert(0, NullKey);
+ BindListControl(control, list, null);
+ }
+
+ #endregion
+
+ #endregion
+
+ /// <summary>
+ /// Signal when an error is exposed.
+ /// </summary>
+ public event EventHandler View_Error;
+
+ /// <summary>
+ /// Pass an error to another control registered to received it.
+ /// </summary>
+ /// <param name="sender">This object</param>
+ /// <param name="e">A ViewArgs instance with the IViewHelper containing the error messages(s).</param>
+ private void View_Error_Send(object sender, ViewArgs e)
+ {
+ if (View_Error != null)
+ {
+ View_Error(sender, e);
+ }
+ }
+
+ /// <summary>
+ /// Reset controls to default state, usually after a Quit or Save event.
+ /// </summary>
+ public virtual void Page_Reset()
+ {
+ ResetControls();
+ }
+
+ private void Page_Load(object sender, EventArgs e)
+ {
+ // Put user code to initialize the page here
+ }
+
+ #region Web Form Designer generated code
+
+ protected override void OnInit(EventArgs e)
+ {
+ //
+ // CODEGEN: This call is required by the ASP.NET Web Form Designer.
+ //
+ InitializeComponent();
+ base.OnInit(e);
+ }
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.Load += new EventHandler(this.Page_Load);
+ }
+
+ #endregion
+ }
+ }
\ No newline at end of file
Added: struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.resx
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.resx?rev=280025&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.resx (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.resx Sat Sep 10 12:04:14 2005
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<root>
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="ResMimeType">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="Version">
+ <value>1.0.0.0</value>
+ </resheader>
+ <resheader name="Reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="Writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/Web.config
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/Web.config?rev=280025&r1=280024&r2=280025&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/Web.config (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/Web.config Sat Sep 10 12:04:14 2005
@@ -97,5 +97,18 @@
/>
</system.web>
+ <runtime>
+ <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+ <dependentAssembly>
+ <assemblyIdentity
+ name="log4net"
+ publicKeyToken="b32731d11ce58905"
+ culture="neutral"/>
+ <bindingRedirect
+ oldVersion="1.2.0.30714"
+ newVersion="1.2.9.0"/>
+ </dependentAssembly>
+ </assemblyBinding>
+ </runtime>
</configuration>
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj?rev=280025&r1=280024&r2=280025&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/Web.csproj Sat Sep 10 12:04:14 2005
@@ -12,12 +12,12 @@
AssemblyName = "Nexus.Web"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
- DefaultHTMLPageLayout = "Grid"
+ DefaultHTMLPageLayout = "Flow"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
PreBuildEvent = ""
- PostBuildEvent = ""
+ PostBuildEvent = "$(SolutionDir)postbuild.bat $(TargetDir) $(TargetName) $(SolutionName) $(SolutionDir)"
RootNamespace = "Nexus.Web"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
@@ -90,29 +90,24 @@
HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
<Reference
- Name = "Core"
- Project = "{7C8CAFD4-1E45-41B4-9963-F51199B12EA7}"
- Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
- />
- <Reference
- Name = "Extras"
- Project = "{7931CACD-0E73-4DD2-A373-FF6A01CE6186}"
- Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ Name = "Spring.Web"
+ AssemblyName = "Spring.Web"
+ HintPath = "..\..\local-cache\SpringNet\Spring.Web.dll"
/>
<Reference
Name = "Spring.Core"
AssemblyName = "Spring.Core"
- HintPath = "..\..\SpringNet.bin\Spring.Core.dll"
- />
- <Reference
- Name = "Spring.Web"
- AssemblyName = "Spring.Web"
- HintPath = "..\..\SpringNet.bin\Spring.Web.dll"
+ HintPath = "..\..\local-cache\SpringNet\Spring.Core.dll"
/>
<Reference
Name = "Agility.Core"
AssemblyName = "Agility.Core"
- HintPath = "..\..\Agility\Core\bin\Debug\Agility.Core.dll"
+ HintPath = "..\..\local-cache\Agility\Agility.Core.dll"
+ />
+ <Reference
+ Name = "Core"
+ Project = "{7C8CAFD4-1E45-41B4-9963-F51199B12EA7}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
</References>
</Build>
@@ -155,6 +150,21 @@
BuildAction = "EmbeddedResource"
/>
<File
+ RelPath = "GridControl.ascx"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "GridControl.ascx.cs"
+ DependentUpon = "GridControl.ascx"
+ SubType = "ASPXCodeBehind"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "GridControl.ascx.resx"
+ DependentUpon = "GridControl.ascx.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
RelPath = "GridViewHelper.cs"
SubType = "Code"
BuildAction = "Compile"
@@ -174,8 +184,28 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "ViewControl.ascx"
+ BuildAction = "Content"
+ />
+ <File
+ RelPath = "ViewControl.ascx.cs"
+ DependentUpon = "ViewControl.ascx"
+ SubType = "ASPXCodeBehind"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "ViewControl.ascx.resx"
+ DependentUpon = "ViewControl.ascx.cs"
+ BuildAction = "EmbeddedResource"
+ />
+ <File
RelPath = "Web.config"
BuildAction = "Content"
+ />
+ <File
+ RelPath = "WebHelper.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
/>
<File
RelPath = "WebViewHelper.cs"
Added: struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs
URL: http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs?rev=280025&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs (added)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/WebHelper.cs Sat Sep 10 12:04:14 2005
@@ -0,0 +1,96 @@
+using System;
+using System.Collections;
+using System.Text;
+using Nexus.Core.Helpers;
+
+namespace Nexus.Web
+{
+ /// <summary>
+ /// Summary description for WebHelper.
+ /// </summary>
+ public class WebHelper : ViewHelper
+ {
+ public override void ExecuteBind(ICollection controls)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void ReadExecute(ICollection controls)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void Bind(ICollection controls)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void Read(ICollection controls)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override string ErrorsText
+ {
+ get { return HtmlMessageBuilder(Alerts); }
+ }
+
+ public override string HintsText
+ {
+ get { return HtmlMessageBuilder(Hints); }
+ }
+
+ #region Message utilities
+
+ /// <summary>
+ /// Build a set of messages using HTML markup.
+ /// </summary>
+ /// <param name="messages">A list of messages</param>
+ /// <returns>HTML markup presenting the messages.</returns>
+ ///
+ private string HtmlMessageList(IList messages)
+ {
+ StringBuilder sb = new StringBuilder("<ul>");
+ foreach (object o in messages)
+ {
+ sb.Append("<li>");
+ sb.Append(o.ToString());
+ sb.Append("</li>");
+ }
+ sb.Append("</ul>");
+
+ return sb.ToString();
+ }
+
+ /// <summary>
+ /// Build a set error messages using HTML markup.
+ /// </summary>
+ /// <param name="store">A context listing errors, if any</param>
+ /// <returns>HTML markup presenting the errors.</returns>
+ ///
+ private string HtmlMessageBuilder(IDictionary store)
+ {
+ string messageMarkup = null;
+ if (store != null)
+ {
+ IList messages = new ArrayList();
+ ICollection keys = store.Keys;
+ foreach (string key in keys)
+ {
+ IList sublist = store[key] as IList;
+ foreach (string message in sublist) messages.Add(message);
+ }
+ messageMarkup = HtmlMessageList(messages);
+ }
+
+ if (messageMarkup != null)
+ {
+ StringBuilder sb = new StringBuilder(messageMarkup);
+ return sb.ToString();
+ }
+ return null;
+ }
+
+ #endregion
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org