XMLC Tutorial: Occasional Gotchas

Contents

  1. Using XMLC with Framesets
  2. Using XMLC when Implementing Interfaces

Using XMLC with Framesets

If you wish to compile an HTML framset with XMLC, you may get a surprise: XMLC will generate an exeception and exit. The good news is that it also tells you how to fix the problem. If you are compiling a frameset, you will need to use the the "-html:frameset" command line option, like this:


$ $ENHYDRA/output/bin/xmlc -html:frameset frameset.html
That will give you a file called frameset.java, as expected. If you gave the <FRAME> tags id attributes, getElement* methods for those tags which return HTMLFrameElement objects. Since this works exactly as the other examples, there is no need to repeat the details.

If you're using framesets inside an Enhydra application, you'll need to know how to tell the Makefile system how to give options to individual presentation objects. Morten Nielsen describes how to do this. I quote:

the Enhydra make system allows options to XMLC. Let's say you have a frameset in a file called Navigation.html. Just add the following to your makfile
                     HTML_CLASSES = NavigationHTML
                     XMLC_Navigation_OPTS = -html:frameset

Using XMLC when Implementing Interfaces

Mark Diekhans, the author of XMLC, explains how to use interfaces to minimize code duplication:

The intention of the -implements option is not to use standard interfaces like cloneable.  It's there to allow one to write utility methods that operate on multiple XMLC-generated objects that share a common set of ids.  The GolfShop demo actually does this, where there are two pages with nearly identical tables.  An interfaces is defined that has the expected methods for accessing the table (getElementXXX).  The XMLC generated classes then implement this interface.

Under golfShop.presentation.xmlc.cart:

cart.ContentsTable is the table interface.

cart.ContentsHTML, checkout.ConfirmHTML, and checkout.MainHTML
all implement ContentsTable

cart.ContentsTableFormatter.fillInTable will then fill in the tables in all of these class.