Plaque It!
Sponsored by: Flash of Genius |
[0001] The invention relates generally to a web server framework, and more particularly to server-side code generation to create hierarchically specified user defined control objects that process client-side user interface elements of a web page.
[0002] A typical web browser receives data from a web server defining the appearance and rudimentary behavior of a web page for display on a client system. In a typical scenario, a user specifies a Uniform Resource Locator (“URL”), a global address of a resource on the World Wide Web, an intranet, and other computer networks to access a desired web site. An example URL is “http://www.microsoft.com/ms.htm”. The first part of the example URL indicates a given protocol (i.e., “http”) to be used in the communication. The second part specifies the domain name (i.e., “www.microsoft.com”) where the resource is located. The third part specifies the resource (i.e., a file called “ms.htm”) within the domain. Accordingly, a browser generates an HTTP (Hypertext Transport Protocol) request associated with the example URL to retrieve the data associated with ms.htm file within the www.microsoft.com domain. A web server hosting the www.microsoft.com site receives the HTTP request and returns the requested web page or resource in an HTTP response to the client system for display in the browser.
[0003] The “ms.htm” file of the example above corresponds to a web page file that includes static HTML (Hypertext Markup Language) code. HTML is a plain-text authoring language used to create documents (e.g., web pages) on the World Wide Web. As such, an HTML file can be retrieved from a web server by a client browser which converts the HTML code to actual visual images or audio components and is thus displayed as a web page. On the client computer systems, this process displays the web page content defined by the delivered HTML file. Using HTML, a developer can, for example, specify formatted text, lists, forms, tables, hypertext links, inline images and sounds, and background graphics for display in the browser. An HTML file, however, is a static file that does not inherently support dynamic generation of web page content. Web page content is the HTML code that is returned to the client for display. Dynamic operation of such relates to a server side application that, as a result of processing steps, generates the HTML code prior to sending as opposed to just sending predetermined code to client browser.
[0004] In order to handle more complex client-server interaction, server-side application programs have developed to handle more complex client-server interaction, such as the providing of dynamic content, e.g., changing stock prices or traffic information. The server-side application program processes the HTTP request and dynamically generates the appropriate HTML code for transmission to the client in an HTTP response. For example, a server-side application program can process query strings and data from Web-based forms provided by the client in HTTP requests to dynamically generate HTML code for transmission in an HTTP response to the client. In essence, the server side application can generate an HTML-type file that is customized based on information in a request from a client. In such a case, there is no static HTML file that is stored on the server; the HTML file is dynamically created at runtime. An exemplary server-side application program may generate HTML code using a sequence of one or more formatted text write operations to a memory structure. Thereafter, the resulting text is transmitted to a client system in an HTTP response, where it is displayed in the browser.
[0005] Developing a server-side application program can be a complex task requiring not only familiarity with normal HTML coding that is used to layout a Web page, but also with programming basics, including one or more programming languages (e.g., C++, Perl, Visual Basic, or Jscript). Unfortunately however, many Web page designers are frequently graphics designers and editors, who provide the human touch but often lack programming experience. Thus, there is a need to provide a simplified web page development framework to create web page files that allows those with less programming experience to develop web page interfaces between server side applications and their respective clients. It is desirable, therefore, to provide a development framework to allow a developer to dynamically create and process a web page with minimal programming.
[0006] One approach to minimize the programming requirements of dynamic web page generation has been the Active Server Page (ASP) framework, provided by Microsoft Corporation. The ASP framework allows developers to create “ASP” web page files that typically include Visual Basic or Jscript code, as well as other HTML code. The ASP file contains declarations or tags that perform various functions as well as VB script or Jscript code. These declarations are generally easier to write than writing actual programming code.
[0007] During operation, the HTTP request specifies the ASP file as the desired resource and, thereafter, the ASP file is used to generate the resulting HTML code in the HTTP response to the client. Furthermore, an ASP file may reference pre-developed or third party server-side library components (e.g., server-side ACTIVEX controls) as well as data bases or other third party applications to ease a given application programming efforts.
[0008] The ASP web page file must be converted at runtime to a script that can be interpreted by a script engine. The script engine typically performs the various declaration-type commands in the ASP file in a consecutive or synchronous manner to achieve the desired result. Compared to files that are compiled and stored as executable files, script files run by script engines are generally slower since the script engine must perform an interpretation function rather than simply running the file.
[0009] One particular problem with compiling a script file into an executable file is that there is or maybe a combination of various languages in the script file. For example, the script file may include components written in HTML and others written in Visual Basic. The script engine uses various operations to interpret these elements at runtime, but no compilers exist to translate the different language components to a single language, i.e., a single source code file. Moreover, in the current server-side application frameworks, the programming required to dynamically manage client-side user interface elements (e.g., text boxes, list boxes, buttons, hypertext links, images, sounds, etc.) within server-side applications can still require sophisticated programming skills. As these server-side processes become more complex, script engines will not be able to continuously keep up with the demands.
[0010] At the same time, programming models that allow reusable elements to be created and specified using easy-to-understand script-based programming language permit a larger universe of potential programmers to create programming objects. As a result, script-language based programming model text addresses the complexity and performance needs of service side programs are highly desirable. For these and other reasons the present invention has been made.
[0011] The present invention relates to a code generation method and apparatus to create an intermediate language or source code file from a server-side resource, the source code file then being compiled into an executable class. The executable class allows for rapid generation of web page control objects that perform server-side functions, including the rendering of client responses. In an embodiment of the present invention, the code generation scheme is capable of creating control objects connected in a hierarchy to handle event processing and the setting of attributes to the specific objects. Furthermore, the code generation method is also capable of connecting objects that have been declared using a template.
[0012] In accordance with preferred aspects, the present invention relates to a method of creating a class in a server computer system memory. The class is used by the server computer system to create server-side objects for dynamically rendering web page content and the web page content is delivered to a client-side computer system and displayed as a web page on the client computer system. In operation, the server computer system receives a request from the client computer system for the web page and wherein the request identifies a dynamic web page content file. The server computer creates a data model to store elements of the dynamic web page content file, evaluates the data model and generates a source code file related to the dynamic web page content file based on the evaluation of the data model. Once the source code file is created, the source code file is compiled to create a compiled class in memory. The process generally ends with the return of a class reference to the server computer system which enables the server computer system to use the class.
[0013] In accordance with other preferred embodiments, the method stores the class in cache memory on the server computer system. Once stored in cache memory, multiple server side page objects can be instantiated from the singular compiled class and the original resource is not used again. Each time a request for the web page is received, the server computer system determines whether a compiled class for that dynamic web page content file resides in memory. If the requested class does not exist in memory, it is created. Once the class is located, the server computer system instantiates server-side processing objects from that class to dynamically generate web page content. The web page content is then rendered and conducted to the client computer system.
[0014] In accordance with yet other embodiments of the present invention, the method step of evaluating the data model involves the recursive traversal of the data model during a plurality of passes. During the first pass, source code is generated and written to the source code file based on the evaluation of the data model during that pass. The data model is constructed using data structures that are linked in a hierarchical manner.
[0015] An embodiment of a computer program product in accordance with the present invention includes a computer program storage medium readable by a computer system and encoding a computer program for executing a computer process of creating a compiled class in memory on the server computer. The compiled class is used to instantiate server-side processing object to render a response corresponding to a requested web page to be displayed on a client computer system. An alternative embodiment of a computer program product in accordance with the present invention includes a computer data signal embodied in a carrier wave by a computing system and encoding a computer program for creating the compiled class on the server.
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
[0022]
[0023]
[0024] An embodiment of the present invention relates to a method of creating a compiled class in memory for a particular web page defined by a dynamic web page content resource or file. Creating the compiled class involves creating a source code file from the web page file. The source code file is then compiled into the class. Once a compiled class exists in memory, a page object can be instantiated to render the response which is sent back to a client for display. The page object generally involves server-side control objects for processing and generating client-side user interface elements which are displayed on the web page. Furthermore, a hierarchy of server-side control objects can be declared in the web page file wherein these objects ultimately cooperate to generate the resulting authoring language code, such as HTML, for display of the web page on the client. The server side controls may consist of pre-built, system provided controls, third-party provided, compiled controls, and user controls created and used according to the present invention.
[0025]
[0026] Remote server
[0027]
[0028] User Control
[0029] In addition, User Control
[0030]
[0031] The communications between the client
[0032] For example, if the URL specifies a static content file
[0033] During its processing, a handler
[0034] The handler
[0035] A handler
[0036]
[0037] If any user control objects are found, operation
[0038] In operation
[0039] Alternatively, the actual creation of the individual server-side control objects may be deferred until the server-side control object is accessed (such as when handling post back input, loading a state, rendering HTML code from the control object, etc.) in operations
[0040] Operation
[0041]
[0042] In
[0043] Once the ASP.NET page
[0044] Similarly, user control library
[0045] The page factory module
[0046] The page object
[0047] In the illustrated embodiment, the control objects in the control object hierarchy
[0048] By virtue of declarations made in the ASP.NET page
[0049]
[0050] The first two line of the file
[0051] <%@ directive {attribute=value}%>
[0052] where directive may include without limitation “page”, “cache” or “import”. Directives are used by the page factory module
[0053] In the particular embodiment of a file
[0054] <% Register TagPrefix=“TagPrefixName” TagName=“Name” src=“fileIdentifier”%>
[0055] The TagPrefix and TagName are used when the user control is referenced later in the file
[0056] In the third line, <html> is a standard HTML starting tag, which is written to the source code file as a literal text such that no additional processing takes place on the information in order to render the resulting HTML code other than a straightforward “write” command. In HTML, the <html> indicates the beginning of the HTML file and is paired with the closing tag on line
[0057] A code declaration block is located at lines
<script runat = “server” [language = “language”][sre = “externalfile”]> ................................... </script>
[0058] where the language and src parameters are optional. In an embodiment of the present invention, code declaration blocks are defined using <script> tags that contain a “runat” attribute having a value set to “server”. Optionally, a “language” attribute may be used to specify the syntax of the inner code. The default language may represent the language configuration of the overall page; however, the “language” attribute in the code declaration block allows a developer to use different languages within the same web page implementation including, for example, Jscript and PERL (Practical Extraction and Report Language). The “<script>” tag may also optionally specify a “src” file, which is an external file from which code is inserted into the dynamic content file for processing by the page compiler. It should be understood that the disclosed syntax is used in one embodiment, however, alternative embodiments may employ different syntaxes within the scope of the present invention.
[0059] In an embodiment of the present invention, a general syntax for declaring HTML control objects is as follows:
<HTMLTag id = “Optional Name” runat = server> ................................... </HTMLTag>
[0060] In addition to standard HTML control tags, an embodiment of the present invention enables developers to create re-usable components that encapsulate common programmatic functionality outside of the standard HTML tag set. These custom server-side control objects are specified using declarative tags within a page file. Custom server-side control object declarations include a “runat” attribute with a value set to “server”. Optionally, the unique “id” attribute may be specified to enable programmatic referencing of the custom control object. In addition, declarative name/value attribute pairs on a tag element specify property arguments and event bindings on a server-side control object. A format for a custom server-side control object declaration is:
[0061] <servercntrlclassname id=“OptionalName” [propertyname=“propval”]runat=server/>
[0062] where servercntrlclassname is a name of an accessible server control class, OptionalName is a unique identifier of the server-side control object, and propval represents an optional property value in the control object.
[0063] Using an alternative declaration syntax, XML declarative statements that possess an XML tag prefix and end with a character sequence “/>” may be used to provide a more concise notation for specifying server-side control objects within a page, using the following format:
[0064] <tagprefix:classname id=“OptionalName”runat=server/>
[0065] where tagprefix is associated with a given control name-space library and classname represents a name of a control in the associated name-space library. An optional propertyvalue is also supported.
[0066] With respect to the particular embodiment in file
[0067] This fact allows developers to create various user controls in different languages while easily permitting the resulting programming objects to interact. A developer may use one language to develop one particular user control in a first programming language best suited for its functionality, for example, string manipulation, and a second user control in a different programming language when significant numeric computations are to be performed. A developer may optimize the use of a programming language for the task to be performed within a single web server.
[0068] The user control is used in line
[0069] <merchant:datagrid id=MySimpleControl runat=server/>
[0070] The reference to “merchant” and “datagrid” above together refer to the user control “MySimpleControl” registered in line
[0071] As stated above, the “merchant” user control is specified within a file having a unique identifier “MySimpleControl.ascx.” This identifier corresponds to a unique filename on the server or a URL on the web that allows the web server
[0072] The user control file
[0073] <merchant:datagrid CustomerState=“MA” runat=server/>
[0074] In this case the public string CustomerState is set to MA for use in the query rather than the CA shown in file
[0075] Because these controls may be used with multiple instances of itself as well as other controls created by potentially other developers who used any number of programming languages, each control of any type (ie. System provided controls, third-party compiled controls, or user controls) operates within its own separate namespace and is isolated from the operation of all other controls. These properties allow the controls to use the programming language of choice. The mechanism which permits the controls to communicate between each other is the use of public properties which may be as few or as many as desired.
[0076] With reference to
[0077] The computer system
[0078] Although the exemplary environment described herein employs a hard disk, a removable magnetic disk
[0079] A number of program modules may be stored on the hard disk, magnetic disk
[0080] The computer system
[0081] When used in a LAN networking environment, the computer system
[0082] In an embodiment of the present invention, the computer
[0083] The embodiments of the invention described herein are implemented as logical steps in one or more computer systems. The logical operations of the present invention are implemented (1) as a sequence of processor-implemented steps executing in one or more computer systems and (2) as interconnected machine modules within one or more computer systems. The implementation is a matter of choice, dependent on the performance requirements of the computer system implementing the invention. Accordingly, the logical operations making up the embodiments of the invention described herein are referred to variously as operations, steps, objects, or modules.
[0084]
[0085] If any user control objects are found, operation
[0086] In operation
[0087] The above specification, examples and data provide a complete description of the manufacture and use of the composition of the invention. Since many embodiments of the invention can be made without departing from the spirit and scope of the invention, the invention resides in the claims hereinafter appended. The invention may also be described in the general context of computer-executable instructions, such as program modules, executed by one or more computers or other devices. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. Typically the functionality of the program modules may be combined or distributed in desired in various embodiments.
[0088] In particular, a web server
[0089] Computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, BC-ROM, digital versatile disks (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by web server
[0090] Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. The term “modulated data signal” means a signal that has one or more of its characteristics set or changed in such a manner as to encode information in the signal. By way of example, and not limitation, communication media includes wired media such as a wired network or direct-wired connection, and wireless media such as acoustic, RF, infrared and other wireless media. Combinations of any of the above should also be included within the scope of computer readable media.