JasperReports Server Hyperlink Formatting

This little nugget applies to Jaspersoft 5.6.x and later, and was brought in due to bleeding effects on hyperlink styles in earlier versions.

There are many things you can do directly with styles in JasperReports, and perhaps hyperlink formatting on a field by field basis could be one of them with a lot of effort and some serious code abuse. But really?! You want to set hyperlinks using conditional styles for every field in every report in your server in an effortful way? Feel free, but there’s another method which is much simpler.

It is a style thing, but within Themes rather than in the reports themselves. Simply put, it’s done by adding style sheet rules like the following to overrides_custom.css in your selected theme.

/* blue, underlined link */
._jrHyperLink {
text-decoration: underline;
color: #0000EE;
/* unvisited link */ ._jrHyperLink:link { color: #0000FF; }
/* visited link */ ._jrHyperLink:visited { color: #800080; }
/* mouse over link */ ._jrHyperLink:hover { color: #FF00FF; }
/* selected link */ ._jrHyperLink:active { color: #FF0000; }

The colour-scheme is limited only by your imagination, Hex codes and – ideally – a little restraint from head-wrecking combinations. Other than that, enjoy.

p.s. That’s right, using JasperReports requires knowing SQL, XML, Java and CSS as a bare minimum.