Jerry Neppl

Subscribe to Jerry Neppl: eMailAlertsEmail Alerts
Get Jerry Neppl: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn


Article

Get the HTML Outta Here!!!

Get the HTML Outta Here!!!

The HTML DataWindow is a great starting tool for any PB programmer. When I began developing applications for the Web knowing little if any HTML, using the HTML DataWindow enabled me to deploy data to the Web immediately.

I became frustrated with a few pages because of the size of the download (over 1100 lines per page). HTML rendering in different browsers was inconsistent. To gain better control over the presentation the client needed and I wanted, some experimentation was necessary.

Here I'll discuss methods I've used to reduce the HTML stream that gets sent back to the browser.

The first method involves little or no HTML scripting but can be more difficult to maintain. The second is how I prefer to generate forms now that I'm more familiar with HTML. Of course, you can keep using the HTML DataWindow, which Sybase has significantly improved in recent releases.

HTML Generation Method 1
Using any of the WYSIWYG tools available, create the form you want to appear on your page. Using the Powersoft Demo DB, create an online form that enables an outside sales person to set up a new customer (see Figure 1).

As you add the form fields to the page, give them the same name as the database column. As an initial value for the field, enter the database column name again. The resulting HTML can be copied to the DataWindow with minor modifications (see Listing 1).

In the PB DataWindow painter add a computed column called c_html and drop in the modified HTML. Be sure to handle any possible null values. After creating the column, save your Data-Window. After you call a retrieve or insertrow and set initial values, grab the computed column from your DataStore and return it to the Web server that made a request. This is best used as a single row entry form.

Advantages

  • Minimal HTML scripting
  • WYSIWYG look and feel
  • Shorter load time for Web pages
Disadvantages
  • Hard to work inside the expression painter for a computed column with a large amount of logic, so keep a copy of the HTML page in case modifications are needed
  • Long-term maintenance can be difficult
HTML Generation Method 2
After the salesperson signs up the new customer, he or she visits other customers in the area. Let's build a listing of customers using the second method: build a string of HTML while looping through a DataStore. I prefer to return a complete HTML table. Assume the data object for the DataStore returns a list of all customers (see Listing 2).

This code will return a string of HTML that's a table of customers or an error message. The best use for this method is a presentation of lists. You can add hyperlinks, drop in images, edit, or delete records.

Advantages

  • Flexible HTML and/or JavaScript
  • On-the-fly construction allows multiple headers and changing of colors
  • It's possible to call multiple Data-Stores to populate drop menus and multiselects; some forms can be up to 100% point-and-click
Disadvantages
  • Requires knowledge of HTML scripting
  • Need to be sure HTML strings render correctly

Transport of HTML Between Web Server and App Server
When not using the HTML Data-Window, some code is needed in the ASP pages. Depending on your enviroment there are different approaches you may want to consider; however, the ASP scripting will be very similar.

Restricted Environment
If you're working in an environment where it's difficult to stop IIS on the Web server to add new tlb/reg files or make many rapid enhancements to a working site, consider using a controlled entry point.

To set this up, create a stateless "control" component with a function called of_get_html (String arg_arglist, String arg_page, String arg_browser, String arg_action, String arg_context, REF String arg_message).

In the ASP build a delimited list of all the arguments. The customer entry page arg_arglist would look like "company_name=PowerTeam Inc.| fname =Jerry|l name=Neppl|...." So all the fields in the form get passed as a named value string, like ASP passes items name=value pairs.

The function of_get_html will be a large CASE statement that does inner component calls or any other processing. By including the arg_browser, arg_action, and arg_context, the option of using the HTMLDW is available.

Advantages

  • Never having to redefine the public interface to Jaguar for IIS
  • Able to change/fix presentation without accessing the Web server
  • Common implementation on ASP pages; only need to change the arg_page
Disadvantages
  • Requires additional string parsing
  • Presentation logic on the application server

Another way to get the HTML out is to use variables by reference with more page-specific functions. For instance, the customer entry page function would look like rtn= of_get_customer(Ref id, Ref company_name, Ref fname....Ref String sz_ html). The ASP script would just assign the variables that get passed into the page.

Advantages

  • Easy to save form field values if an item doesn't pass validation because unless you modifiy them, the variable will stay the same.
  • Places more presentation logic on the Web server
Disadvantages
  • More public interface requires better developer access to the Web server
HTML Generation with HTMLDW
The HTML DataWindow has many advantages, and it will continue to improve.

Advantages

  • Gets PB developer(s) to the Web fast
  • Handles transport of HTML with no modification
  • Sybase continues to improve this tool
  • Easy to maintain Disadvantages
    • Tied into Sybase's JavaScript interpretation
    • Current download time
    Each of these methods has its place; it's up to you to decide which is best for your application. Sybase keeps enhancing this tool: there will be page caching to reduce the download size. Now, if someone could only get IE and NS to work exactly alike...but what fun would that be?

    The method for calling to a component from an ASP can be found at www. powerobjects.com/jaguar/activexproxy.html.

  • More Stories By Jerry Neppl

    Jerry Neppl, previously CEO of a small liquidation company, has been working for PowerTeam, Inc., in Minneapolis, for the past year and a half, having fun and getting
    paid to play everyday.

    Comments (0)

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.