Method to the Madness: Custom XHTML input for XPage field
Wed 9 Feb 2011, 10:49 AM
by Ben Langhinrichs
On page 67 of Mastering XPages (What? You don't have Mastering XPages yet? Well, we're hardly going to wait around a week for it to get delivered, so you can order it for Kindle at Mastering XPages - Kindle edition and look for Chapter 4, listing 4.18), there is a discussion about filling in content for a rich text field using escaped HTML with the xp:inputRichText tag.
So, our second method will be GeniiRTChunk.GenerateHTML. The general help for the method is below, but we will use a very specific set of parameters which I will get to later. This will allow us to do some fancy tricks, but will also use the Midas LSX's high fidelity rendering engine.
Version added: 2.21
Converts the specified chunk into HTML controlled by the various arguments and properties, and returns the result as a text stream. Result can be complete, compliant, well formed HTML or XHTML, or it can be a compliant fragment of HTML or XHTML that can be embedded in an HTML or XHTML result from elsewhere. Ideal for use with agents generating HTML rapidly and completely but needing to incorporate rich text fields in the results. Please note that style mappings created through the SetStyleMapping method will also effect HTML and XHTML generation. The ClearStyleMappings method can be called to eliminate previously created style mappings.
text = geniiRTChunk.GenerateHTML(subdefinition [, html_type [, properties]])
String. Optional. The definition of the subchunk, or "" if the whole chunk should be used.
String. Optional. Currently "HTML" and XHTML are the only valid options, but in future versions the default may change. HTML refers to compliant HTML 4.01, while XHTML refers to compliant XHTML 1.0.
String. Optional. Properties which control the generation of the HTML are defined in the document Working with HTML generation. In addition, there is a property called OutputToEvent which can be set to "Yes" or "No". If it is set to "No" or not set at all, the return value for the GenerateHTML call will be all of the HTML generated concatenated together. If the size is greater than 64KB, the result will be truncated. If the OutputToEvent property is set to "Yes", an ActOnText event will be triggered for each 8000 characters (roughly), and all limits on the size of the HTML to be generated are removed.
Copyright © 2011 Genii Software Ltd.