|
ASP Code Pattern |
Overview
The browser must support dynamic HTML and Java script. Internet Explorer 9.0, Netscape Navigator 9.0 and later versions of these products meet the minimum requirements.
ASP is a middle layer providing communication between the business object component and the browser. VB script in the ASP creates and uses instances of the business object components (ActiveX dlls). The same business object components are also used in a traditional VB form user interface.
ASP makes requests to the business objects to obtain information about properties, permitted values and other meta-data. Business objects provide this information in the form of and XML document .
XML from the business object is transformed using the XSL templates into HTML and sent to the browser. Each style of browser interface (list, detail, search) has a corresponding XSL template . Visible Developer customers can modify the XSL templates to alter the look and feel of the interface.
The business objects access the application database using dynamic SQL or stored procedures - both are generated by Visible Developer.
What do ASP code patterns generate?
ASP Code Patterns generate a List and Detail ASP page for specific business objects in your model. In addition to these pages, a search page is generated, common to all business objects, for filtering data.
ASP pages make use of customizable XSL templates to transform the business object's XML into HTML.
The logical layer (Layer 2) contains Visible Developer's business objects. It is compiled as an Active-X DLL and deployed on the web server.
How do ASP pages interact with existing VB Business Objects?
ASP pages make requests to the business objects to obtain information about their properties, permitted values and meta-data. Business objects provide all of this information in the form of XML. To obtain their XML, business objects interact with Visible Developer's run-time DLL (Visible Common Business Object Library). The ASP pages then transform the XML, using the XSL templates, into HTML and send it to the browser.
return to menu
Getting started with the ASP Code Pattern
Register the ASP Code Patterns
Before you start using the ASP Code Patterns you need to register them in every VisDev repository that you plan to use. If you change your repository you will need to ensure that the ASP Code Patterns are registered in that repository. Visible Developer maintains information about all of the available code patterns and their 'settings' in the repository. This information will be saved in the repository whenever you register a new code pattern and when you make changes to the code pattern settings.
Registering the ASP Code Patterns is very easy. To register the code patterns, install the ASP Code Patterns first. Then start Visible Developer and choose the repository (Tools-Preferences), in which the ASP Code Patterns are to be registered. Then choose File-Register Code Pattern and browse to the file C:\Program Files\Visible\Developer\ASP Code Pattern\ASP Code Pattern\mtrASPCodePattern.dll.
Change Code pattern settings
During code generation Visible Developer will use the code pattern settings you specify. Default settings are provided for your convenience and you can also specify your own settings for each of the ASP pages, List, Detail and Startup.
Generate ASP code
To generate code follow these steps.
1) Make certain that you are using the repository in which the ASP Code Patterns have been registered.
2) Use 'Tools-Preferences' to select the ASP code patterns to be displayed on the build menu.
3) Select the code pattern you want to use from the build menu and choose the business objects that you want to generate.
Regenerate business objects (Layer 2) and use the new run-time DLL
ASP pages must use the new run-time DLL, Visible common business object library, installed with the ASP code patterns. The latest version number of the DLL is 2.6.0.2.
Layer 2 components must also be regenerated using the new StdCodePatterns2 DLL, which is installed along with the ASP Code Patterns, and recompiled.
return to menu
XSL templates
What are the different types of templates generated?
There are 4 XSL templates that are installed along with the ASP Code Patterns.
1) Search.xsl - used by list ASP pages to parse the View's search XML and store it as HTML in session variables. Search criteria displayed on the search.asp page will correspond to the list's search properties.
2) BusinessObjectList.xsl - used by list ASP pages to parse the list class' XML.
3) DetailFrm.xsl - used by detail ASP pages to parse the logical class' XML.
4) MasterDetail.xsl - used by master detail pages to parse the classes for master detail pages
How do I use the XSL templates provided with the installation?
The XSL templates must be copied to the same virtual directory that contains the generated ASP pages.
Do I have to use the XSL templates provided with the installation?
The XSL templates provided with this installation are only provided as a starting point. You may modify the XSL templates to suit your requirements or write your own templates as long as they can parse the business object XML correctly. We encourage you to make changes to these templates. One example would be to add sorting capability to the BusinessObjectList.xsl template.
return to menu
OVERVIEW:
Diagram 1: Top Level of ASP
ASP Code Patterns generate a List and Detail ASP page for each of the business objects in your model. In addition to these pages specific to each business object, a search page is generated which all business objects use for filtering data.
From the Start page you navigate to the List page in 'OPEN' mode. From the List page you can go to the Detail page, do a search (to filter data) or go back to the Start page.
return to menu
START PAGE:
An asp start page is generated for each model. The start page contains buttons, which will take you to the corresponding List ASP page.
return to menu
LIST PAGE:
Each business object has its own List ASP page and is based on the view, which the list class uses.
Three navigation buttons are available (New, Search and Close). To create a new record click the 'New' button and it will take you to the Detail page. When the 'Search' button is clicked the search page is displayed. Each item on the list page is hyperlinked to take you to the detail ASP page.
You can specify the number of records to be displayed at a time, in the code pattern settings for the ASP List page. Page navigation hyperlinks are provided if the search results do not fit on a single page.
return to menu
DETAIL PAGE:
From the detail ASP page you can create a new record, update an existing record or delete a record. When you close this page, it takes you back to the list ASP page.
Detail page is loaded in different modes 'OPEN', 'NEW', 'ADD', 'UPDATE', 'DELETE' and 'CLOSE'. The diagrams below explain the flow in each of these modes.
Diagram 2: Detail Page in 'New' mode
When you click the 'New' button on the detail page it gets reloaded in 'New' mode and the controls are ready for data to be entered. Any default values that are specified for the properties get loaded automatically. The mode gets switched to 'Add' when the Add button is clicked (at the same time a parameter is passed to check for mandatory properties).
Diagram 3: Detail Page in 'Add' mode
In the 'Add' mode, mandatory properties are checked and the record is added only if all of the mandatory values are provided. Control is then redirected to the List page.
Diagram 4: Detail Page in 'Close' mode
When the 'Close' button is clicked, detail page switches to 'Close' mode. In the CheckFlowControl sub the control is redirected to the List page.
Diagram 5: Detail Page in 'Delete' mode
When the 'Delete' button is clicked, the Detail page connects to the business object, reads the business object using it's ID and deletes the current record. Control is then redirected to the List page.
Diagram 6: Detail Page in 'Open' mode
From the List page, the Detail page is loaded in 'Open' mode, when you click on a hyperlink associated with an item. The Detail page connects to the business object, reads the business object using it's ID and opens the current record. The mode is switched to 'Update' when the 'Update' button is clicked.
Diagram 7: Detail Page in 'Update' mode
In the 'Update' mode, mandatory properties are first checked and the record is updated only if all of the mandatory values are provided. Control is then redirected to the List page.
return to menu
Server-side subs and functions used by the Detail ASP Page
Get Parameters: This function gathers information from the 'Request' object. The requested mode of operation, the ID (passed in as XML) of the record to be displayed and the flag to check for mandatory properties are retrieved and stored as session variables.
Connect: This function various objects that will be used later. DOM Objects for parsing XML/XSL, the logical business object and the message queue for the current business object are created. (In a later version we will use the message object to return messages to the Detail page.)
ReadItem: Reads data corresponding to the detail item's ID.
CheckFlowControl: Determines how the processing should continue. If the mode is 'Close' then control is passed to the List ASP page. If the mode is Add/Update, mandatory properties are checked and the detail page is reloaded if any of the mandatory properties are missing.
SaveProperties: This function is only called in the Add or Update modes. All of the business object's current properties are saved here.
DisplayErrors: This sub will be used to retrieve error messages and display them.
BuildDisplayFields: This sub will get the business objects XML corresponding to the current record and use XSL to transform the XML to HTML.
return to menu
SEARCH PAGE:
The search page displays the list's search properties, which is used to filter records that will be displayed on the List ASP page. The search criteria for each of the business objects are stored in a session variable. The search criteria will be used during the remaining session.
return to menu
MASTER-DETAIL PAGE:
Master-detail forms display information about the parent and child records are displayed on one or more tabs. The detail records can be edited just as in a Detail ASP page.
return to menu
|