JHeadstart ADF Generation with Custom Templates – using custom properties when none are available

Most our ADF application is generated. For many reasons, including an easier upgrade to 11g later on. That means a lot of fiddling with custom generator templates – the Velocity files. Occasionally I we have to make use of the JHeadstart Custom Properties to achieve advanced functionality. In our extensions to the standard templates we can refer to those custom properties and generate this functionality, driven by their values.

However, JHeadstart does not offer custom properties for Regions. I have requested them before, but the 10.1.3.2 release that came out a couple of weeks ago does not have them. That means that my new advanced functionality for regions cannot be generated. Or can it?

Time for a dirty trick, a workaround in the truest sense of the word:....

We would like to be able to show a tooltip when the mouse hovers over the Region Title. That is not such a problem, just a matter of setting the onmouseover and onmouseout attributes on the panelHeader. However, where to get the title and text for the tooltip from. Unfortunately, a Region does not have Custom Properties.

That is where the really dirty workaround comes in: we abuse the template properties.

Instead of using Custom Properties – that we do not have for Regions – we use the Template Properties DATA_PAGE and LOV_PAGE (those do not apply to Regions anyway) for the Tooltip Title and Tooltip Text respectively.
 

JHeadstart ADF Generation with Custom Templates - using custom properties when none are available regioncustomproperties001 

In the custom version of the verticalRegionContainer.vm template, I have added the lines that will generate the onmouseout and onmouseover attributes to the panelHeader element generated for the sub-regions:

        #if (${subRegion.templateBindingsContainer.templateBindings.DATA_PAGE})
onmouseover="showToolTip(this,'${subRegion.templateBindingsContainer.templateBindings.DATA_PAGE}','${subRegion.templateBindingsContainer.templateBindings.LOV_PAGE}');"
onmouseout="hideToolTip()"
#end
 

The challenge for me was to find the correct syntax for extracting the Template properties. We can get to the Template Properties through the templateBindingsContainer.templateBindings property on the subRegion; that returns a Map of all Template Properties. 

The result of generating our region with the custom template using the ‘custom properties’ set on the region:

   <af:panelGroup id="EmpInDeptRegionsPanelGroup">
<af:panelHeader text="#{nls['FINANCIAL_TITLE']}"
id="EmpInDeptRegionsfinancialPanelHeader"
onmouseover="showToolTip(this,'Region Tooltip Title','Region Tooltip Text');"
onmouseout="hideToolTip()">
<amis:PlainDiv styleClass="contentRuler"/>
 

JHeadstart ADF Generation with Custom Templates - using custom properties when none are available regioncustomproperties002 

 

Resources

JHeadstart Developer’s Guide

Apache Velocity User’s Guide