Generating the cooltip for ADF applications (using JHeadstart)

Our end users – inspired by the Interaction Designers – have requested a superduper tooltip for their fields. Not the shy title popup label that browsers show for elements with the title attribute set (limited in number of characters and layout options), no, a real sturdy tooltip. It has to look something like this:

Generating the cooltip for ADF applications (using JHeadstart) colotip003

Implementing this tooltip on all fields that we want to specify one for is somewhat of a challenge. Not because it is complicated: it is very simple to add such a hovering tooltip to an input component. All it takes is ....
setting the onmouseout and onmouseover attributes:

  <af:inputText id="EmpInDeptEname"

The real challenge is adding these attributes to all elements that we need a tooltip for. That is lot of work, not a lot of fun. However, we generate our application using JHeadstart. So we should be able to leverage the generator.

And that happens to be very easy. All we need to do is change a few lines in a single template. The file templates/default/common/common_items.vm contains the macro ITEM_HINT. It will set either the shortDesc or the hint attribute of Form Input Elements. However, with just a tiny change, we can make it write the onmouseover and onmouseout attributes that we desire:

#macro (ITEM_HINT)
## 1.7AMIS1.0 commented out #if (${JHS.current.item.hintText}!='')#if ($JHS.service.showHintTextAsPopup)#JHS_PROP("shortDesc" ${JHS.nls(${JHS.current.item.hintText}, "${}_${}_HINT")})#else#JHS_PROP("tip" ${JHS.nls(${JHS.current.item.hintText}, "${}_${}_HINT")})#end#end#end
## 1.7AMIS1.0 modified, to support AMIS style tooltip
#if (${JHS.current.item.hintText}!='') onmouseover="showToolTip(this,'${JHS.nls(${JHS.current.item.promptInForm}, "${}_${}")}','${JHS.nls(${JHS.current.item.hintText}, "${}_${}_HINT")}');"

Note: you should (and we did that, honestly) create your own template as a copy of common_items.vm, rather than change the original template file as shipped with JHeadstart. We created /templates/amis/common/amis_common_items.vm and registered our own file in templates/config/jag-config.xml.

To also generate the tooltip into the column header, to achieve this result:

Generating the cooltip for ADF applications (using JHeadstart) colotip005

we need to add a call to the ITEM_HINT() macro in the COLUMN_HEADER_LABEL():

value="${JHS.nls(${JHS.current.item.promptInTable}, "${}_TABLE_${}")}"
## 1.7AMIS1.0 Added the call to ITEM_HINT()

There is one tiny little issue: the tooltip should also be shown when the item is read only. However, it is not: the onmouseover and onmouseout attributes are not rendered for the items in read only mode. I am not sure yet how to deal with that particular problem. wrapping every item in a PanelGroup and setting the mouse attribute on the PanelGroup? Use disabled rather than read-only? Make use of the fact that every read only element is rendered using a SPAN that has the element’s ID as its ID?