Author: husted
Date: Mon Sep 19 07:20:41 2005
New Revision: 290166

URL: http://svn.apache.org/viewcvs?rev=290166&view=rev
Log:
OVR-21
+ ViewControl: Add additional forms for Read and ReadExecute. Extend docs for 
Page_Reset. Rename NullIfEmpty to NullOnEmpty for legibility. 
+ GridControl: Add Page_Reset method to reset indexes if paging. Remove labels 
from ResetControls. Add GetMessages to auto-populate controls.

Modified:
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll
    struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb
    struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs
    struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.dll?rev=290166&r1=290165&r2=290166&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Core.pdb?rev=290166&r1=290165&r2=290166&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.dll?rev=290166&r1=290165&r2=290166&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Extras.pdb?rev=290166&r1=290165&r2=290166&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.dll?rev=290166&r1=290165&r2=290166&view=diff
==============================================================================
Binary files - no diff available.

Modified: struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Test/bin/Debug/Nexus.Test.pdb?rev=290166&r1=290165&r2=290166&view=diff
==============================================================================
Binary files - no diff available.

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=290166&r1=290165&r2=290166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs Mon Sep 19 
07:20:41 2005
@@ -225,8 +225,9 @@
                        Grid.DataSource = list;
                }
 
-               public virtual void DataBind()
+               public override void DataBind()
                {
+                       base.DataBind();
                        Grid.DataBind();
                }
 
@@ -312,41 +313,46 @@
 
                private void ReadGridControls(ControlCollection controls, 
IDictionary dictionary, string[] keys, bool nullIfEmpty)
                {
-                       int i = 0;
+                       int i = -1;
                        foreach (Control t in controls)
                        {
+                               i++;
                                string key = keys[i];
                                if (IsTextBox(t))
                                {
                                        TextBox x = (TextBox) t;
-                                       string value = (nullIfEmpty) ? 
NullIfEmpty(x.Text) : x.Text;
+                                       string value = (nullIfEmpty) ? 
NullOnEmpty(x.Text) : x.Text;
                                        dictionary.Add(key, value);
+                                       continue;
                                }
                                if (IsLabel(t))
                                {
                                        Label x = (Label) t;
-                                       string value = (nullIfEmpty) ? 
NullIfEmpty(x.Text) : x.Text;
+                                       string value = (nullIfEmpty) ? 
NullOnEmpty(x.Text) : x.Text;
                                        dictionary.Add(key, value);
+                                       continue;
                                }
                                if (IsListControl(t))
                                {
                                        ListControl x = (ListControl) t;
-                                       string value = (nullIfEmpty) ? 
NullIfEmpty(x.SelectedValue) : x.SelectedValue;
+                                       string value = (nullIfEmpty) ? 
NullOnEmpty(x.SelectedValue) : x.SelectedValue;
                                        dictionary.Add(key, value);
+                                       continue;
                                }
                                if (IsCheckBox(t))
                                {
                                        CheckBox x = (CheckBox) t;
                                        string value = (x.Checked) ? key : null;
                                        dictionary.Add(key, value);
+                                       continue;
                                }
                                if (IsRadioButton(t))
                                {
                                        RadioButton x = (RadioButton) t;
                                        string value = (x.Checked) ? key : null;
                                        dictionary.Add(key, value);
+                                       continue;
                                }
-                               i++;
                        }
                }
 
@@ -421,7 +427,7 @@
 
                public virtual IViewHelper ExecuteList(IDictionary criteria)
                {
-                       IViewHelper helper = ReadExecute(ListCommand);
+                       IViewHelper helper = ReadExecute(ListCommand, criteria);
                        bool okay = helper.IsNominal;
                        if (okay) BindGrid(helper); // DoBindGrid = helper;
                        return helper;
@@ -464,6 +470,19 @@
                        return okay;
                }
 
+               public virtual bool Open(IDictionary criteria)
+               {
+                       Page_Reset();
+                       list_Criteria = criteria;
+                       return Open();
+               }
+
+               public void Reset(IDictionary criteria)
+               {
+                       list_ResetIndex();
+                       Open(criteria);                 
+               }
+
                protected virtual void list_Item(string commandName, int index)
                {
                        switch (commandName)
@@ -617,9 +636,20 @@
 
                #endregion
 
-               public void list_Item_Click(int index)
+               public virtual void list_Item_Click(int index)
+               {
+                       // Override to provide implementation
+               }
+
+               /// <summary>
+               /// Reset state for this control, including any ViewState 
attributes
+               /// and the page indexes (@see(list_ResetIndex)), 
+               /// usually on a new Open event or on a Quit event,
+               /// </summary>
+               public override void Page_Reset()
                {
-                       //
+                       list_ResetIndex();
+                       base.Page_Reset();
                }
 
                private void Page_Load(object sender, EventArgs e)

Modified: struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs?rev=290166&r1=290165&r2=290166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/IViewControl.cs Mon Sep 19 
07:20:41 2005
@@ -25,6 +25,9 @@
                IViewHelper ExecuteBind(ControlCollection controls, string 
command);
                IViewHelper ExecuteBind(string command);
 
+               void ReadExecute(IViewHelper helper, bool nullIfEmpty);
+               void ReadExecute(IViewHelper helper);
+
                IViewHelper Read(string command, bool nullIfEmpty);
                IViewHelper Read(string command);
 

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=290166&r1=290165&r2=290166&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs (original)
+++ struts/sandbox/trunk/overdrive/Nexus/Web/ViewControl.ascx.cs Mon Sep 19 
07:20:41 2005
@@ -40,7 +40,7 @@
 
                #region String utilities 
 
-               protected string NullIfEmpty(string input)
+               protected string NullOnEmpty(string input)
                {
                        return (string.Empty.Equals(input)) ? null : input;
                }
@@ -98,25 +98,47 @@
                #region Control utilities
 
                /// <summary>
-               /// Return true if control is a Label.
+               /// Return true if control is a button.
                /// </summary>
                /// <param name="control">Control to test.</param>
-               /// <returns>True if control is a Label</returns>
+               /// <returns>True if control is a Button</returns>
                /// 
-               protected bool IsLabel(Control control)
+               protected bool IsButton(Control control)
                {
-                       return (typeof (Label).Equals(control.GetType()));
+                       return (typeof (Button).Equals(control.GetType()));
                }
 
                /// <summary>
-               /// Return true if control is a TextBox.
+               /// 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 HyperLink.
                /// </summary>
                /// <param name="control">Control to test.</param>
                /// <returns>True if control is a TextBox</returns>
                /// 
-               protected bool IsTextBox(Control control)
+               protected bool IsHyperLink(Control control)
                {
-                       return (typeof (TextBox).Equals(control.GetType()));
+                       return (typeof (HyperLink).Equals(control.GetType()));
+               }
+
+               /// <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>
@@ -138,25 +160,25 @@
                }
 
                /// <summary>
-               /// Return true if control is a Checkbox.
+               /// Return true if control is a RadioButton.
                /// </summary>
                /// <param name="control">Control to test.</param>
-               /// <returns>True if control is a Checkbox</returns>
+               /// <returns>True if control is a RadioButton</returns>
                /// 
-               protected bool IsCheckBox(Control control)
+               protected bool IsRadioButton(Control control)
                {
-                       return (typeof (CheckBox).Equals(control.GetType()));
+                       return (typeof (RadioButton).Equals(control.GetType()));
                }
 
                /// <summary>
-               /// Return true if control is a RadioButton.
+               /// Return true if control is a TextBox.
                /// </summary>
                /// <param name="control">Control to test.</param>
-               /// <returns>True if control is a RadioButton</returns>
+               /// <returns>True if control is a TextBox</returns>
                /// 
-               protected bool IsRadioButton(Control control)
+               protected bool IsTextBox(Control control)
                {
-                       return (typeof (RadioButton).Equals(control.GetType()));
+                       return (typeof (TextBox).Equals(control.GetType()));
                }
 
                /// <summary>
@@ -191,11 +213,6 @@
                        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;
@@ -303,27 +320,27 @@
                        return trimmed;
                }
 
-               private void ReadControls(ControlCollection controls, 
IDictionary dictionary, string prefix, string list_suffix, bool nullIfEmpty)
+               private void ReadControls(ControlCollection controls, 
IDictionary dictionary, string prefix, string list_suffix, bool nullOnEmpty)
                {
                        foreach (Control t in controls)
                        {
                                if (IsTextBox(t))
                                {
                                        TextBox x = (TextBox) t;
-                                       string value = (nullIfEmpty) ? 
NullIfEmpty(x.Text) : x.Text;
+                                       string value = (nullOnEmpty) ? 
NullOnEmpty(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;
+                                       string value = (nullOnEmpty) ? 
NullOnEmpty(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;
+                                       string value = (nullOnEmpty) ? 
NullOnEmpty(x.SelectedValue) : x.SelectedValue;
                                        dictionary.Add(root, value);
                                }
                                if (IsCheckBox(t))
@@ -343,16 +360,37 @@
                        }
                }
 
-               public IViewHelper Read(ControlCollection controls, string 
command, bool nullIfEmpty)
+               public void Read(ControlCollection controls, IDictionary 
dictionary, bool nullIfEmpty)
+               {
+                       ReadControls(controls, dictionary, null, ListSuffix, 
nullIfEmpty);
+               }
+
+               public void ReadExecute(ControlCollection controls, IViewHelper 
helper, bool nullIfEmpty)
+               {
+                       Read(this.Controls, helper.Criteria, nullIfEmpty);
+                       helper.Execute();
+               }
+               
+               public void ReadExecute(IViewHelper helper, bool nullIfEmpty)
+               {
+                       ReadExecute(this.Controls, helper, nullIfEmpty);
+               }
+
+               public void ReadExecute(IViewHelper helper)
+               {
+                       ReadExecute(helper, true);
+               }
+               
+               public IViewHelper Read(ControlCollection controls, string 
command, bool nullOnEmpty)
                {
                        IViewHelper helper = GetHelperFor(command);
-                       ReadControls(controls, helper.Criteria, null, 
ListSuffix, nullIfEmpty);
+                       ReadControls(controls, helper.Criteria, null, 
ListSuffix, nullOnEmpty);
                        return helper;
                }
 
-               public IViewHelper Read(string command, bool nullIfEmpty)
+               public IViewHelper Read(string command, bool nullOnEmpty)
                {
-                       return Read(this.Controls, command, nullIfEmpty);
+                       return Read(this.Controls, command, nullOnEmpty);
                }
 
                public IViewHelper Read(string command)
@@ -360,9 +398,9 @@
                        return Read(this.Controls, command, true);
                }
 
-               public IViewHelper ReadExecute(ControlCollection collection, 
string command, bool nullIfEmpty)
+               public IViewHelper ReadExecute(ControlCollection collection, 
string command, bool nullOnEmpty)
                {
-                       IViewHelper helper = Read(collection, command, 
nullIfEmpty);
+                       IViewHelper helper = Read(collection, command, 
nullOnEmpty);
                        helper.Execute();
                        return helper;
                }
@@ -403,6 +441,38 @@
                        return helper;
                }
 
+               private static string TITLE = "_title";
+               private static string LINK = "_link";
+               
+               public virtual void GetMessages(ControlCollection controls)
+               {
+                       foreach (Control t in controls)
+                       {
+                               if (IsButton(t))
+                               {                                       
+                                       Button x = (Button) t;
+                                       x.Text = GetMessage(x.ID);
+                               }
+                               if (IsHyperLink(t))
+                               {                                       
+                                       HyperLink x = (HyperLink) t;
+                                       x.Text = GetMessage(x.ID + TITLE);
+                                       x.NavigateUrl = GetMessage(x.ID + LINK);
+                                       continue;
+                               }
+                               if (IsLabel(t))
+                               {                                       
+                                       Label x = (Label) t;
+                                       x.Text = GetMessage(x.ID);
+                               }
+                       }                       
+               }
+
+               public virtual void GetMessages()
+               {
+                       GetMessages(Controls);
+               }
+
                #endregion
 
                #region ListControl methods 
@@ -494,8 +564,20 @@
                }
 
                /// <summary>
-               /// Reset controls to default state, usually after a Quit or 
Save event.
+               /// Reset state for this control, including any ViewState 
attributes, 
+               /// usually on a new Open event or on a Quit event.
                /// </summary>
+               /// <remarks><p>
+               /// Subclasses can override to clear any attributes manages 
through ViewState, 
+               /// and to retain any default values that should survive a 
reset.
+               /// If overridden, the best practice is to call base.Page_Reset 
+               /// rather than call ResetControls directly.
+               /// </p><p>
+               /// Usually, Page_Reset should *not* be called on a Save event, 
+               /// since the state at Save might be needed by another 
component. 
+               /// The typical idiom is to call Page_Reset when an Open method 
is passed new parameters 
+               /// or on a Quit event.
+               /// </p></remarks>
                public virtual void Page_Reset()
                {
                        ResetControls();



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to