Generating the cooltip for ADF applications (using JHeadstart)

Lucas Jellema

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:

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:

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?

Next Post

You want to build it with ADF, but you do not want it to look like ADF. What do you do? (come to S290737 during OOW2007)

Well, at the very least come to my presentation Building Real Oracle Application Development Framework (Oracle ADF) Applications: A Learning Experience at OOW next week:  S290737, Thursday 4.00pm (Moscone South 300). One of the things I will tell you is how we created this carefully, tailor-designed and attractive User Interface […]
%d bloggers like this: