Usage of IlvHitmapDefinition class to customize a tooltip in JSF

Article ID: 2390
Last updated: 29 May, 2018
Article ID: 2390
Last updated: 29 May, 2018
Revision: 3
Views: 865
Posted: 10 Jan, 2014
by Dean J.
Updated: 29 May, 2018
by Gargani A.

Question

How to customize a tooltip in a JSF application, using <jvf:tooltipInteractor> tag ?

Answer

The <jvf:tooltipInteractor>  tag is designed to work with a <jvf:view>. The default implementation since JViews 8.7 is to show the name of the graphic object as tooltip.

However, you can customize this behavior to show something else, for instance the tooltip of your graphic object. Here is how to proceed :

Let's assume your graphic object has a tooltip set via CSS or java code.

1) First, you need to create a sub class of IlvHitmapDefinition:

/**
* A customized hitmap definition example.
*/
public class HitmapDefinition extends IlvHitmapDefinition {

public HitmapDefinition() {
}

/** Returns the tool tip text of the graphic object;
* @see ilog.views.servlet.IlvHitmapDefinition#getTooltip(ilog.views.IlvGraphic)
*/
@Override
protected String getTooltip(IlvGraphic graphic) {
if (graphic == null) return "";
String tooltip = graphic.getToolTipText();
if (tooltip != null && tooltip.length()>0)
    return tooltip;
return super.getTooltip(graphic);
} 
}

2) In web.xml, you need to tell JViews diagrammer servlet to use your class

<servlet>
<servlet-name>CustomizedFacesDiagrammerServlet</servlet-name>
<servlet-class>ilog.views.diagrammer.faces.dhtml.servlet.IlvFacesDiagrammerServlet</servlet-class>
<init-param>
<param-name>hitmap</param-name>
<param-value>HitmapDefinition</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>CustomizedFacesDiagrammerServlet</servlet-name>
<url-pattern>/wms-faces-servlet</url-pattern>
</servlet-mapping>

3) In index.jsp, you need to tell the diagrammer view to use the customized servlet:

<jvdf:diagrammerView id='mapView' 
width='640' height='400' 
diagrammer="#{support.diagram}" 
interactorId="tooltipInteractor" 
servlet="wms-faces-servlet" />

Attached is a sample file illustrating what is described above.

In order for this sample to work, you need to add in your WebContentWEB-INFlib directory the following jars :

batik-jviews-svggen-8.7.jar

batik-jviews-tiff-8.7.jar

jsf-api-1.2_07-b03-FCS.jar

jsf-impl-1.2_07-b03-FCS.jar

jstl-1_1-mr2-api.jar

jviews-diagrammer-all.jar

jviews-framework-all.jar

jviews-maps-all.jar

jviews-palette-shared-symbols-8.7.jar

Note: IlvHitmapDefinition was introduced in JViews 8.7.

This article was:   Helpful | Not helpful
Report an issue
Article ID: 2390
Last updated: 29 May, 2018
Revision: 3
Views: 865
Posted: 10 Jan, 2014 by Dean J.
Updated: 29 May, 2018 by Gargani A.
Attached files

Also listed in


Others in this category