Subscribe via Feed

An Easy Way to Set the TAG of Computed Text to Aid in Semantic HTML Structures

Paul Hannan, Aug 24, 2010 9:25:54 AM

There's a new property added to the Computed Field control in 852 called 'tagName'. This started life as an enhancement request from fellow IBMer and XPager Thomas Gumz and this property allows the control to emit a tag for computed text, like h1, h2, h3 tags to aid in creating semantic HTML structures for documents (to help in search engine optimizations, etc).


It's pretty easy to use. Add or use any Computed Field control, , select the All Properties panel and in 'basics' you'll see the new property...

Then it's a matter of selecting from the drop down what you need - div, span, h1, h2 or h3


For example...

                                    value="#{javascript:@DbTitle()}" tagName="h1">
               

...will render as...

XPages 8.5.2 Demonstration Application (24/08/2010)



Your not restricted to the available options in the drop down. You can compute any tag name...

                                    value="#{javascript:@DbTitle()}">
                    "blockquote"}]]>
               


...which will render as...

<blockquote id="view:_id1:computedField1" class="xspTextComputedField">XPages 8.5.2 Demonstration Application (25/06/2010)blockquote>



If you needed to do this kind of thing before 852, you needed to manually type in the HTML tag in the Source view, and on the computed field control, disable theme and remove the control id,
like so:







...which is a bit messy.

Hope this helps.
p.


 



1 responses to An Easy Way to Set the TAG of Computed Text to Aid in Semantic HTML Structures

Frank van der Linden, August 24, 2010 10:47 AM

This is brilliant new features. Your HTML code will be cleaner.