Generating the cooltip for ADF applications (using JHeadstart)

Lucas Jellema
0 0
Read Time:2 Minute, 57 Second

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"
value="#{bindings.EmpInDeptEname.inputValue}"
label="#{nls['EMPINDEPT_ENAME']}"
onmouseover="showToolTip(this,'#{nls['EMPINDEPT_ENAME']}','#{nls['EMPINDEPT_ENAME_HINT']});"
onmouseout="hideToolTip();"></af:inputText>
 

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}, "${JHS.current.group.name}_${JHS.current.item.name}_HINT")})#else#JHS_PROP("tip" ${JHS.nls(${JHS.current.item.hintText}, "${JHS.current.group.name}_${JHS.current.item.name}_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.current.group.name}_${JHS.current.item.name}")}','${JHS.nls(${JHS.current.item.hintText}, "${JHS.current.group.name}_${JHS.current.item.name}_HINT")}');"
onmouseout="hideToolTip();"#end#end

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():

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

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?

About Post Author

Lucas Jellema

Lucas Jellema, active in IT (and with Oracle) since 1994. Oracle ACE Director and Oracle Developer Champion. Solution architect and developer on diverse areas including SQL, JavaScript, Kubernetes & Docker, Machine Learning, Java, SOA and microservices, events in various shapes and forms and many other things. Author of the Oracle Press book Oracle SOA Suite 12c Handbook. Frequent presenter on user groups and community events and conferences such as JavaOne, Oracle Code, CodeOne, NLJUG JFall and Oracle OpenWorld.
Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %
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: