public interface JRHyperlink extends JRCloneable
hyperlinkType
attribute (see getHyperlinkTypeValue()
) attribute
can hold any text value, but by default, the engine recognizes the following standard hyperlink types:
None
- By default, neither the text fields nor the images represent
hyperlinks, even if the special hyperlink expressions are present.Reference
- The current hyperlink points to an external resource specified
by the corresponding <hyperlinkReferenceExpression>
element, usually a
URL.LocalAnchor
- The current hyperlink points to a local anchor specified by the
corresponding <hyperlinkAnchorExpression>
tag.LocalPage
- The current hyperlink points to a one-based page index within the
current document specified by the corresponding <hyperlinkPageExpression>
element.RemoteAnchor
- The current hyperlink points to an anchor specified by the
<hyperlinkAnchorExpression>
element within an external document indicated
by the corresponding <hyperlinkReferenceExpression>
elementRemotePage
- The current hyperlink points to a one-based page index specified by
the <hyperlinkPageExpression>
element, within an external document
indicated by the corresponding <hyperlinkReferenceExpression>
elementhyperlinkType
value not in the preceding list is considered a custom hyperlink
type. More details about those are given in the "Custom Hyperlinks" section, which
follows.
<hyperlinkReferenceExpression>
- see the related method getHyperlinkReferenceExpression()
<hyperlinkAnchorExpression>
- see the related method getHyperlinkAnchorExpression()
<hyperlinkPageExpression>
- see the related method getHyperlinkPageExpression()
java.lang.String
and the third should
return java.lang.Integer
values.
There are situations when hyperlinks should be displayed only if a certain condition is met. In such cases one can
use the Boolean expression <hyperlinkWhenExpression>
(see getHyperlinkWhenExpression()
).
hyperlinkTarget
(see getHyperlinkTarget()
). Its purpose is to
help customize the behavior of the specified link when it is clicked in the viewer.
Possible values for this attribute:
Self
- The document to which the hyperlink points will be opened in the current
viewer windowBlank
- The document to which the hyperlink points will be opened in a new viewer
windowParent
- The document to which the hyperlink points will be opened in the parent
frameTop
- The document to which the hyperlink points will be opened in the top frameSelf
.
JRHyperlinkTargetProducer
interface. Hyperlink target producers can be added to the JasperReports engine in a
transparent way, by registering instances of the
JRHyperlinkTargetProducerFactory
class as extensions.
When the JasperReports engine encounters a custom target value specified in the target
attribute of a hyperlink, it first interrogates all registered hyperlink target producer
factories to obtain a target producer for this custom hyperlink. If no target producer is
found, the engine looks for any hyperlink parameter having the same name as the
specified custom target. If one is found, the engine takes its value as the true target to
use. If no parameter is found, the custom target value is considered a frame name into
which the hyperlink document must be opened.
<hyperlinkTooltipExpression>
tag (see getHyperlinkTooltipExpression()
).
The type of the expression should be java.lang.String
. The ToolTip expression will be
evaluated along with the hyperlink and the result will be saved in the generated document.
The built-in JasperReports viewer and the HTML exporter will honor the hyperlink
ToolTip and display it while the user views the report.
<hyperlinkParameter>
tag. These parameters are made available to the custom
hyperlink handler so that it can generate a final hyperlink depending on the parameter
values.
Hyperlink parameter expressions are evaluated along with the hyperlink, and the results
are kept in the generated hyperlink object as parameter values.
When exporting the report to other formats such as HTML or PDF, the user can set a
factory of hyperlink handlers using the
getHyperlinkProducerFactory()
export configuration setting. A factory is an implementation of
JRHyperlinkProducerFactory
, which is
responsible for creating a hyperlink handler for a custom hyperlink type. This hyperlink
handler created by the factory is a
JRHyperlinkProducer
instance, and it is
used for generating a hyperlink reference in the export document by assembling
hyperlink parameters and other information supplied at export time.
To handle custom hyperlinks in the built-in Swing viewer, one needs to register a
hyperlink listener by calling
addHyperlinkListener(JRHyperlinkListener)
on the
JRViewerPanel
component. The listener is an
implementation of the JRHyperlinkListener
interface. When a report hyperlink gets clicked, the listener queries the hyperlink type
and performs the desired actions.
<anchorNameExpression>
tag transforms that particular text field or image into a local anchor of the resulting
document, to which hyperlinks can point. The anchor will bear the name returned after
evaluation of the anchor name expression, which should always return
java.lang.String
values.
bookmarkLevel
attribute available for all hyperlink elements in JasperReports.JRAnchor
,
JRHyperlinkProducer
,
JRHyperlinkProducerFactory
,
JRHyperlinkTargetProducer
,
JRHyperlinkTargetProducerFactory
,
JRHyperlinkListener
Modifier and Type | Method and Description |
---|---|
JRExpression |
getHyperlinkAnchorExpression()
Returns the expression whose value represents the anchor.
|
JRExpression |
getHyperlinkPageExpression()
Returns an integer representing the page index of the link.
|
JRHyperlinkParameter[] |
getHyperlinkParameters()
Returns the list of hyperlink parameters.
|
JRExpression |
getHyperlinkReferenceExpression()
Returns the expression whose value represents the hyperlink reference.
|
byte |
getHyperlinkTarget()
Retrieves the hyperlink target for the element.
|
JRExpression |
getHyperlinkTooltipExpression()
Returns the expression which will generate the hyperlink tooltip.
|
HyperlinkTypeEnum |
getHyperlinkTypeValue()
Retrieves the hyperlink type for the element.
|
JRExpression |
getHyperlinkWhenExpression()
Returns the expression that is evaluated in order to decide if the hyperlink should be displayed.
|
String |
getLinkTarget()
Returns the hyperlink target name.
|
String |
getLinkType()
Returns the hyperlink type.
|
clone
HyperlinkTypeEnum getHyperlinkTypeValue()
The actual hyperlink type is determined by getLinkType()
.
This method can is used to determine whether the hyperlink type is one of the
built-in types or a custom type.
When hyperlink is of custom type, CUSTOM
is returned.
getLinkType()
byte getHyperlinkTarget()
The actual hyperlink target is determined by getLinkTarget()
.
This method can is used to determine whether the hyperlink target is one of the
built-in target names or a custom one.
When hyperlink has a custom target name, HyperlinkTargetEnum.CUSTOM
is returned.
getLinkTarget()
JRExpression getHyperlinkReferenceExpression()
JRExpression getHyperlinkWhenExpression()
JRExpression getHyperlinkAnchorExpression()
JRExpression getHyperlinkPageExpression()
String getLinkType()
The type can be one of the built-in types (Reference, LocalAnchor, LocalPage, RemoteAnchor, RemotePage), or can be an arbitrary type.
String getLinkTarget()
The type can be one of the built-in names (Self, Blank, Top, Parent), or can be an arbitrary name.
JRHyperlinkParameter[] getHyperlinkParameters()
The parameters can be used by custom hyperlink types to generate dynamic links.
JRExpression getHyperlinkTooltipExpression()
Copyright © 2017. All rights reserved.