Kbase P98730: What are the WebSpeed-specific file types?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/13/2004 |
|
Status: Unverified
GOAL:
What are the WebSpeed-specific file types?
FIX:
There are three primary types of files that are used for WebSpeed development:
HTML files with embedded SpeedScript
CGI wrappers
Mapped web objects
1. HTML files with embedded SpeedScript
SpeedScript is Progress 4GL code that is added directly to an HTML file to create dynamic output of HTML source code. You add SpeedScript to an HTML file by using special HTML tags and formatting. When an HTML file containing SpeedScript compiles, the 4GL code is parsed and compiled into a .r file that recreates the original HTML. Dynamic content that was created by SpeedScript and any additional processing logic added by SpeedScript is added to the static HTML output. This SpeedScript code is resolved on the server.
The <script Language="SpeedScript"> Tag
You add SpeedScript to HTML files using the <script Language="SpeedScript"> tag. Similar to other Script tags in HTML, you close the tag with a </script> tag. If you include any 4GL code between the open and closing SpeedScript tags, it compiles when the HTML file compiles.
Unlike other uses of the script tag for script languages used in HTML programming, the SpeedScript (and any included 4GL code) never displays and SpeedScript is not a client-side script language. WebSpeed uses the <script> tag as a way to parse out any added code; the resulting .r file is a Progress procedure that outputs HTML source code.
The SpeedScript tag is useful for adding large amounts of 4GL code to an HTML file, including variable definitions, looping statements, and conditional logic.
Using SpeedScript Expression Escapes ( ` )
In addition to the SpeedScript tag, you can add single data elements such as variables, field names, and function values to an HTML file by using expression escapes. Expression escapes are marked by wrapping the data element name in a set of back-tics ( ` ).
The code between ticks compiles and the resulting string is output as HTML source code. This is useful for displaying variables or field values. The output of information using this method can be formatted using the Progress FORMAT command. The values of variables and database information output between expression escapes is substituted at run time.
2. CGI wrappers
A CGI wrapper is a structured procedure you use to output HTML source code.
The CGI wrapper uses special WebSpeed statements to output character to the browser. A CGI wrapper has no associated .htm file; it only has a procedure (.p) file and its corresponding compiled r-code file.
Outputting HTML using {&OUT}
A CGI wrapper uses a special WebSpeed preprocessor to direct output from the procedure to the browser. You use the {&OUT} preprocessor as a way to "display" content to the Web.
The {&OUT} directs output to the stream that returns content to the browser.
Using {&OUT} in a program
This example shows using the {&OUT} preprocessor to display information.
DEFINE VARIABLE vcCustName AS CHARACTER NO-UNDO.
DEFINE VARIABLE vcToday AS CHARACTER NO-UNDO.
FIND FIRST CUSTOMER NO-LOCK NO-ERROR.
IF AVAILABLE CUSTOMER THEN DO:
ASSIGN vcCustName = Customer.Name.
END.
ELSE DO:
ASSIGN vcCustName = "No Customer Available".
END.
ASSIGN vcToday = STRING(today).
{&OUT}
"<HTML>":U SKIP
"<HEAD>":U SKIP
"<TITLE> CGI Wrapper </TITLE>":U SKIP
"</HEAD>":U SKIP
"<BODY>":U SKIP
.
{&OUT} "<CENTER><B>Sample. CGI Wrapper File</B></CENTER><BR>" SKIP
"The first customer in the database is <b>" vcCustName
"</b>.<br>" SKIP
"Todays Date is <b>" vcToday ".</b><br>" SKIP.
{&OUT}
"</BODY>":U SKIP
"</HTML>":U SKIP
.
Notice that all HTML output is included in a {&OUT} statement. Also, the variable definitions in a standard CGI wrapper would be included in the Definitions section of the structured procedure. They only are included here, along with the other code, as an example
The process-web-request subprocedure
Each CGI wrapper contains an internal procedure called process-web-request. This section initiates the output to the browser and provides the HTML tags required to complete a valid HTML page. This is where you add code to complete the HTML page.
3. Mapped web objects
A mapped web object takes a standard HTML page, including form elements, and maps each form element to a database field, a temporary table field, or SmartDataObject data element. The mapping procedure outputs the value of the Progress element at the time the page is rendered as the initial value of the form element in the HTML page. Complex data manipulation is performed using the mapped web object, and much of the logic needed to perform database updates is included as default behavior in a mapped web object. The mapping process is completed by the Mapping Wizard and generates a large amount of code to display information and standard database update logic.
The web-frame When an HTML page is mapped, each of the data elements is added to a Progress frame called web-frame. This frame is used to manipulate the data that displays in the browser. The screen values of elements in this frame are displayed when the page is rendered in the position of the original mapped tag.
This is a simple web-frame definition.
DEFINE FRAME Web-Frame
ab_unmap.dtoday
&IF '{&WINDOW-SYSTEM}' = 'TTY':U &THEN AT ROW 1 COL 1
&ELSE AT ROW 1 COL 1 &ENDIF HELP
"" NO-LABEL FORMAT "X(256)":U
VIEW-AS FILL-IN
&IF '{&WINDOW-SYSTEM}' = 'TTY':U &THEN SIZE 20 BY 1
&ELSE SIZE 20 BY 1 &ENDIF
Customer.Name
&IF '{&WINDOW-SYSTEM}' = 'TTY':U &THEN AT ROW 1 COL 1
&ELSE AT ROW 1 COL 1 &ENDIF NO-LABEL
VIEW-AS FILL-IN
&IF '{&WINDOW-SYSTEM}' = 'TTY':U &THEN SIZE 20 BY 1
&ELSE SIZE 20 BY 1 &ENDIF
WITH 1 DOWN KEEP-TAB-ORDER OVERLAY
SIDE-LABELS
AT COL 1 ROW 1
SIZE 80 BY 20.
This frame has two elements:
· The ab_unmap.dtoday element displays the date; it is not related to a databa.se field. The ab_unmap table is a temporary table that accounts for data elements that are not mapped to specific database fields or SmartDataObject elements.
· The Customer.Name element displays the customer name of the current customer record when the page is rendered. The Mapping Wizard creates this definition..