Collection Contents Index Getting started with PowerDynamo Improving the template pdf/chap10.pdf

First Guide to SQL Anywhere Studio
   PART 2. Getting Results with SQL Anywhere Studio
     CHAPTER 10. Building a Dynamic Web Site with PowerDynamo       

Creating a template


The basic Dynamo template includes queries as well as formatting and static HTML. PowerDynamo sends embedded queries to Adaptive Server Anywhere, formats the results as defined by the formatting, and sends the formatted results along with any static HTML and text to the Web server, which sends it to the Web client that requested it.

Templates vs Scripts    
Templates and scripts are very similar in PowerDynamo. The main difference is that templates consist of HTML as well as DynaScript and SQL queries. Scripts contain a scripting language such as DynaScript without any surrounding HTML. If you would like the framework (template) provided for you when creating a Web page with a SQL query and HTML, it is recommended that you use the Add Template wizard. If you wish to create a fairly empty Web page that you can edit yourself, it is recommended that you use the Add Script wizard.

In this project you will build a template that includes a query and HTML formatting. It involves the following tasks:

Top of page  About embedded queries and formatting

Embedded queries are stored in the template and are delimited by special HTML comment tags as seen in the following graphic. Dynamo provides wizards to help you create simple templates containing queries and HTML. It is a good idea to familiarize yourself with the tags commonly used in PowerDynamo so that you may later modify your own scripts and customize them to your own needs.

For Info     For more information about using Dynamo tags and the DynaScript scripting language see the PowerDynamo User's Guide.

Top of page  Create the Employees template with an embedded query

PowerDynamo provides an easy way to build a query and to define formatting for data output with the template wizard.

In this task, you will create a template called Employees that displays basic employee data from the sample database.

  1. Double-click PowerDynamo in the left pane of Sybase Central.

  2. Double-click ASASite.

  3. Double-click the ASASite folder.

  4. Double-click Add Template in the right pane of Sybase Central.

  5. Enter Employees as the name of the Template, and click Next.

  6. Enter a description of the template, such as Employee contact information and click Next.

    The descriptions will display as a level-one heading in the Web page you are creating.

  7. You may be asked which connection you wish to use for this template. Select inherited. This indicates that you wish to use the same connection as was used for the root /Site. Click Next

  8. You can either type a SQL statement or use the SQL Query Editor to build one. In this task, you will use the SQL Query Editor

    Click Select.

    The Edit Query dialog box appears.

  9. Select the Tables tab if it is not already displayed.

  10. Select the employee table by either double clicking on it or by selecting it and clicking Add. Add the department table in the same manner.

  11. Select the Columns tab.

  12. Click the plus sign next to the employee table name to display the available columns.

  13. Select the following columns either by double clicking on them or by selecting the column and clicking the Add button:

  14. Open the department table by clicking on the plus sign and select the dept_name column.

    The columns appear in the Selected Columns list.

  15. Select the Sort tab. Select the following columns to sort by:

  16. Select the Test tab.

  17. Click Test to see if the query returns data.

    Data appears in the data window, verifying the validity of the query.

  18. Click OK.

  19. Click Next.

  20. Choose Table with Headings as the default HTML format for the data.

  21. Click Finish.

    A new template, Employees.stm, appears in the Sybase Central workspace. You will view the resulting document from a Web browser in the next task.

Top of page  Start the Personal Web Server and a Web Browser to view the output of Employees.stm

  1. Start the Personal Web Server:

    Once the Personal Web Server has been started a small tray icon will appear on the Windows start bar.

  2. Start a Web browser such as Netscape or Microsoft Internet Explorer.

  3. Open the following URL in you Web browser:

http://localhost/ASASite/Employees.stm
or
http://your machine's name/ASASite/Employees.stm
or 
http://your machine's IP number/ASASite/Employees.stm

If you get an error message in the browser window, double-check the Dynamo configuration.

Another reason for an error may be that you have another Web server loaded on your computer that uses the default port number, 80. You may have to map the ASASite to a port number other than the default. If necessary, see the PowerDynamo User's Guide for information on how to do this. Many users have Web servers on their computers without knowing it.

Top of page  View the output

The document appears in the Web browser window. It displays data in a table format, since you chose Table with Headings as the HTML display format in Task 1. The following graphics illustrate the template content that was generated from the Add Template wizard.

The following graphic illustrates how the above template looks when viewed through a browser:

Top of page  

Collection Contents Index Getting started with PowerDynamo Improving the template pdf/chap10.pdf