Consultor Eletrônico



Kbase 18973: New HTML Conditional Tag Support in Apptivity 3.1
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/13/1999
SUMMARY:

One of the new features in Apptivity 3.1 is conditional tag support in
HTML projects. Now it's possible to perform conditional logic within
the HTML file itself but executed on the server, so it's completely
browser independent. Prior to this enhancement, everything except the
simplest types of conditional page processing required writing a
custom tag and coding the conditional logic in Java.

SOLUTION:

The following simple example shows how to dynamically modify the HTML
if the browser supports DHTML. This is a modified version of the
AppStar project.

Changes to the AppStar project:

1) Edit appstarServlet.java. Find the following lines in the
service method around line 118:

// Create a new abService object which encapsulates the
// important information about this request.
abService theService = new abService(this, req, res, theSession);


Insert the following lines after those above. This uses the
SmartClient class to determine if DHTML is supported by the
browser:

// Determine if the browser supports DHTML. Save the result so
// it can be tested with the "if" tag like:
// if eval="%smartclient.dhtmlEnabled%"
theService.setServiceValue("smartclient.dhtmlEnabled",
theService.getClient().isDhtmlEnabled() ? "true" : "false");

If HTTP Sessions are being used, this value along with other
browser related tests, could be saved in the HttpSession object
to avoid making this test for every request.

2) Edit the supplier.html file (among others).
Replace the custom tag so it looks like this:

<apptivity comment="Execute this block for DHTML enabled
browsers"/>
<apptivity if eval="%smartclient.dhtmlEnabled%"/>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD><A HREF="JavaScript:showLayer('dynamic0')"><IMG
SRC="`imageAlias`/main.gif" BORDER=0></A></TD>
<TD><A HREF="JavaScript:showLayer('dynamic1')"><IMG
SRC="`imageAlias`
otes.gif" BORDER=0></A></TD>
</TR>
</TABLE>
<apptivity endif/>

The above logic was formerly hard coded as a series of out.println
statements in a custom tag. Now all the conditional HTML is included
in the page. This provides for easier maintenance and better separation of logic from presentation.

This conditional processing allows Apptivity to be used to transform websites with static content into dynamic sites that provide a richer user experience -- whether or not database access is utilized.