David's XMLC Tips
XMLC supports two XML parsers for building a DOM template: the Xerces DOM and the LazyDOM, an XMLC enhancement subclass of the Xerces DOM. Although the LazyDOM usually delivers superior performance, thanks to its capability to instantiate only selected portions of the DOM, the Xerces DOM might perform better if your page is extensively dynamic.
Sometimes you just cannot figure out why your resultant markup is coming out the way it is. Use the DOMInfo class as a runtime approach to dumping the current state of your page template at any point once it has been factory loaded. Here's an example of using DOMInfo to take a look at a portion of a page template dealing with a single row in an HTML table.
There's more than one way to reference XMLC's dynamic content labeling id attributes. If your table labeling id attribute is named "PartsTable," you can either use the hardwired named getElementPartsTable() or the more flexible getElementById method, as in "getElementById("PartsTable"). There is no performance penalty, and you can do robust coding with friendlier error checking. By checking the returned value of the getElementById() method, you can double check that the id attribute was not left out by the markup designer during a page maintenance revamp. Instead of dealing with a crash-and-burn situation when your code tries to invoke a nonexistent getElementPartsTable(), you instead alert the QA department that the expected PartsTable attribute is no longer there.
Barracuda is the exciting new presentation framework for XMLC featuring client-type detection, forms handling and validation, and other common presentation-handling needs. But, with its comprehensiveness, it can be a little daunting. So, why not test the water by only using the portions of it that address immediate needs. For example, rather than mastering its hierarchical event handling or assortment of user interface components, why not just use the localization ant taskdef to better take advantage of its excellent automation of separating and organizing localized strings for markup pages?
PrintWriter out = newPrinterWrite(new OutputStreamWriter(System.out, "UTF-8")); myPageHTML page = (myPageHTML) xmlc.getFactory().create(myPageHTML.class); Node subTemplate = myPage.getElementCustomerRow(); DOMInof.printTree("Customer Row template", subTemplate, DOMInfo.PRINT_ATTR_DETAILS,out);
For example, in your markup, you might have the following default value and associated message:
In your Java code, the following will really let your users know you mean business.
HTMLInputElement input = page.getElementPasswordLength(); input.getAttribute("value").setValue("16");