using System; using System.Web.UI; using System.Web.UI.WebControls; using Nexus.Core; using Nexus.Core.Helpers; using Nexus.Web; using PhoneBook.Web.Controls; namespace PhoneBook.Web.Forms { /// /// Display a list of employees with their telephone extension [OVR-5]. /// ///

/// This is a starter version of the Directory page /// that presents the list /// without offering more advanced features. ///

/// public class Directory : Page { #region Messages /// /// Provide a message for the List All command. /// /// public const string msg_LIST_ALL_CMD = "SHOW ALL"; #endregion #region Page Properties protected Panel error_panel; protected Label error_label; /// /// Display a list of error messages. /// public IViewHelper Page_Error { set { error_label.Text = value.AlertsText; error_panel.Visible = true; } } /// /// Provide filed for Catalog property. /// private IRequestCatalog _Catalog; /// /// Provide reference to the Catalog (object factory) for this application. /// ///

/// Subclasses adding EventHandlers /// should pass a reference to themselves with a ViewArgs instance, /// encapsulating the Helper. ///

public virtual IRequestCatalog Catalog { get { return _Catalog; } set { _Catalog = value; } } #endregion #region Event handlers /// /// Present matching directory entries. /// /// protected Lister lister; /// /// Capture input values to filter a list of directory entries. /// /// protected Finder finder; /// /// Handle Filter Changed event by opening the Lister control /// and passing through the search criteria /// provided by the event arts. /// /// Event source /// Runtime arguements /// protected void finder_FilterChanged(object sender, EventArgs e) { ViewArgs a = e as ViewArgs; IViewHelper helper = a.Helper; lister.Open(helper.Criteria); } #endregion #region Page Events /// /// Handle View_Error event by presenting the error message /// provided by the Helper class. /// /// Event source /// Runtime parameters /// private void View_Error(object sender, EventArgs e) { ViewArgs v = e as ViewArgs; if (v == null) throw new ArgumentException("View_Error: !(e is ViewArgs)"); IViewHelper helper = v.Helper; if (helper != null) Page_Error = helper; else throw new ArgumentException("View_Error: (e.helper==null)"); } /// /// Initialize controls by registering for View Error events /// and passing through our Catalog instance. /// /// Control to initialize /// private void View_Init(ViewControl c) { c.View_Alert += new EventHandler(View_Error); c.Catalog = Catalog; // ISSUE: Why isn't control injection working? } /// /// Handle Page Init event by initalizing the controls. /// /// private void Page_Init() { View_Init(finder); View_Init(lister); } /// /// Handle page's load event. /// /// Event source /// Runtime parameters /// private void Page_Load(object sender, EventArgs e) { error_panel.Visible = false; } #endregion #region Web Form Designer generated code /// /// Initialize components. /// /// Runtime parameters /// protected override void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); Page_Init(); } /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// /// private void InitializeComponent() { this.Load += new EventHandler(this.Page_Load); } #endregion } }