Cornerstone Training

download Cornerstone Training

of 98

  • date post

    11-Apr-2015
  • Category

    Documents

  • view

    62
  • download

    9

Embed Size (px)

Transcript of Cornerstone Training

Cornerstone Application Framework Training Class 1

1

Table of ContentsCornerstone History.............................................................................................................................................3 Class Setup...........................................................................................................................................................3 Architecture Overview.........................................................................................................................................4 Developing UIs with Cornerstone vs. Classic ASP.NET.....................................................................................5 Project Structure and Conventions......................................................................................................................5 Developing the HelloWorld Solution..................................................................................................................6 Module 1: Creating the Application Solution..................................................................................................7 Module 2: Integrating the ValueMapper........................................................................................................14 Module 3: Adding a Controller Project..........................................................................................................22 Module 4: Form Layout and Handling Page Events......................................................................................27 Module 5: Consuming Web Services.............................................................................................................37 Module 6: Populating a GridView with Web Service Data...........................................................................55 Module 7: HelloWorld Base Page and Using the Cornerstone SearchControl..............................................76 Module 8: Consuming Data from a Database................................................................................................88 Advanced Topics................................................................................................................................................97 Appendix: Coding Standards.............................................................................................................................97 Appendix: ASP.NET Page Lifecycle.................................................................................................................97 Appendix: Level 3 Environment Concerns.......................................................................................................97

2

Cornerstone HistoryThe Cornerstone Application Framework is the evolution of an idea that was first put into practice with the SOE initiative. The goal was to create a consistent, effective toolkit that enables rapid application development cycles by allowing the developer to concentrate more on implementing business requirements and less on tweaking the UI. Cornerstone provides all the building blocks necessary to get a standardized Level 3 application up and running in no time. After several years of development and testing, this toolkit has now been made available to a wider audience of Level 3 developers and will continue to live up to its initial purpose by enabling developers to react quickly and produce outstanding results in our continually changing business environment.

Class SetupThis class is designed to give you hands-on experience with Cornerstone. You will need the following on your development machine: 1. Visual Studio 2005 with Service Pack 1 2. The latest version of the ASP.NET 2.0 AJAX Extensions (http://www.asp.net/ajax/downloads/) 3. Cornerstone template and xsd files installed (your instructor will help if you have not already done this) 4. Remote access enabled (you will use Microsoft Terminal Server Client to connect to your machine)

3

Architecture OverviewThe controls, modules, and other primary features of Cornerstone are entirely compatible with and may be used by a traditional ASP.NET application, but have been designed with a particular reference architecture in mind. At a high-level this architecture is based on a standard three-tier MVC approach containing presentation, controller, and data access levels.

The Cornerstone reference design dismisses use of the .ASPX page and relies entirely on the codebehind (aspx.cs) and related embedded controls as the presentation tier. This allows for a more consistent control tree and simplifies debugging. Many of the Cornerstone controls are instantiated by using L3ControlFactory, which adheres to the factory pattern and provides consistency. The controller tier acts as a conduit between the presentation tier and the data access tier. It processes and responds to events and routes data accordingly. The flow controller, which guides page flow and manages state and transfer parameters, also resides here. 4

The data access tier encapsulates all web service calls and database interaction. A ServiceFactory is used to instantiate these object based on UDDI endpoints or provides application independence by seamlessly allowing for stubs (mock data) to be used in their place. Enabling or disabling service stubs is simple process involving a web.config change, and can be performed at runtime.

Developing UIs with Cornerstone vs. Classic ASP.NETDeveloping a UI with Cornerstone differs from building it in the classic ASP.NET fashion in that the 1. VS Designer is not used (although it's been discussed that a future version of Cornerstone web controls could be made to support the VS Designer) 2. Page layout and controls are controlled entirely in the code-behind file 3. There is only one line of text in the .aspx file of the page

Project Structure and Conventions (Insert project diagram here) Summary of naming conventions for Projects Pages Controls Classes Namespaces Summary of Coding standards Summary of File location

5

Developing the HelloWorld Solution

6

Module 1: Creating the Application SolutionModule Goal:

In this module we will begin building the sample application HelloWorld with the following features: Cornerstone enable Single page that displays a static message Header and Footer user controls Styling based on a CSS file

7

Procedure 1.1: Creating the HelloWorld web site

1. Create a folder on the c: drive called "HelloWorld_Solution". This is where the application source files will be kept. 2. Open Visual Studio 3. Select FileNewWeb Site 4. Choose "ASP.NET AJAX-Enabled Web site" (or depending on your Visual Studio installation "ASP .NET AJAX-Enabled Web Application"), set the Location to "c:\HelloWorld_Solution\HelloWord", the Language to "Visual C#" and hit OK

5. In the Solution Explorer window, right click the HelloWorld web site and select Property Page. 6. Add a reference to the Cornerstone.Web.dll assembly from the path your instructor gives you.

8

Procedure 1.2: Adding a HelloWorld page

1. Delete the web page Default.aspx. 2. Right click the HelloWorld web site and add a new web form called "HelloWorldPage.aspx"

3. Open the Source view for HelloWorldPage.aspx and delete all but the first line

4. Right click the HelloWorld.aspx file and select "Set As Start Page" 5. Open the code-behind file for HelloWorldPage.aspx.cs by clicking the '+' next HelloWorldPage.aspx.cs in the Solution Explorer and double clicking the HelloWorldPage.aspx.cs file. 6. Delete all of the "using " statements at the top of the file except the one for System. 7. Add the statement "using Level3.Cornerstone.Web.WebControls;" to the top of the file under "using System;" 8. Change the base class of this page from "System.Web.UI.Page" to "L3PageTemplate" 9. Delete the entire Page_Load method. 10. Add the following methods:protected override void OnInit(EventArgs e)

9

{ base.OnInit(e); EnsureChildControls(); } protected override void CreateChildControls() { base.CreateChildControls(); Controls.Add(L3ControlFactory.CreateLabel("Hello World!")); }

11. Save all files and browse the page.

10

Source File Code 1.2: HelloWorldPage.aspx

Source File Code 1.2: HelloWorldPage.aspx.csusing System; using Level3.Cornerstone.Web.WebControls; public partial class HelloWorldPage : L3PageTemplate { protected override void OnInit(EventArgs e) { base.OnInit(e); EnsureChildControls(); } protected override void CreateChildControls() { base.CreateChildControls(); Controls.Add((L3ControlFactory.CreateLabel("Hello World"))); } }

11

Procedure 1.3: Adding a Header, Footer, and Style Sheet

1. Create a folder in the web site called "Styles" 2. Add the file HelloWorldStyle.css to the Styles folder from the location your instructor gives you. 3. Open Web.config and add the following under the line ""

4. Right click the HelloWorld web site and select "New Folder" 5. Rename the new folder "UserControls". This is where the header and footer for the application pages will be kept. 6. Right click the "UserControls" folder and select "Add New Item" 7. Add a "Web User Control" called "Header.ascx" 8. Repeat the previous two steps to add "Footer.ascx" 9. Add the following to Header.ascx source view 10. Open the source view for Header.ascx and add the following to the end of the file: HelloWorld Header

11. Open the source view for Footer.ascx and add the following to the end of the file: HelloWorld Footer

12. Save all files and browse the page.

12

Source File Code 1.3: Header.ascx HelloWorld Header

Source File Code 1.3: Footer.ascx HelloWorld Footer

13

Module 2: Integrating the ValueMapperModule Goal: