Genii Weblog

Method to the Madness: Custom XHTML input for XPage field

Wed 9 Feb 2011, 10:49 AM



by Ben Langhinrichs
Follow up to Method to the Madness: Connecting to an XPage with Midas

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.

GenerateHTML method  

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.
Defined in
GeniiRTChunk class
Syntax
textgeniiRTChunk.GenerateHTML(subdefinition [html_type  [properties]])
Parameters
subdefinition
String.  Optional.  The definition of the subchunk, or "" if the whole chunk should be used.
html_type
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.
properties
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.

What has been said:


971.1. Ulrich Krause
(09.02.2011 16:04)

Still no clue where this leads us to ...

A new kind of flux compensator perhaps ?


971.2. Ben Langhinrichs
(02/09/2011 04:13 PM)

I can't give you too much information, or there will be no reason to keep reading these posts. Still, I am leaving broad hints that should become more clear.


971.3. Ulrich Krause
(09.02.2011 16:37)

No problem. Will see the result at EntwicklerCamp. :)