Skip to content

Instantly share code, notes, and snippets.

@maravilloso
Created June 12, 2013 06:35
Show Gist options
  • Save maravilloso/5763253 to your computer and use it in GitHub Desktop.
Save maravilloso/5763253 to your computer and use it in GitHub Desktop.
Syntax for referring to report objects
Syntax Description
=================== ======================================================
$F{name_field} Specifies the name_field field ("F" means field).
$V{name_variable} Specifies the name_ variable variable.
$P{name_parameter} Specifies the name_parameter parameter.
$P!{name_parameter} Special syntax used in the report SQL query to indicate that the parameter
does not have to be dealt as a value to transfer to a prepared statement,
but that it represents a little piece of the query.
$R{resource_key} Special syntax for localization of strings.
$X{op, field, param} For dynamic [NOT] IN clauses. See bellow:
JasperReports provides a special syntax to use with a where condition: the clause IN and NOT IN.
The clause is used to check whether a particular value is present in a discrete set of values.
Here is an example:
SELECT * FROM ORDERS WHERE SHIPCOUNTRY IS IN ('USA','Italy','Germany')
The syntax to make the previous query dynamic is:
SELECT * FROM ORDERS WHERE $X{IN, SHIPCOUNTRY, myCountries}
where the $X{} clause recognizes three parameters:
• Type of function to apply (IN or NOT IN)
• Table Field name to be evaluated
• Parameter name (must be or inherit java.util.Collection)
JasperReports will handle special characters in each value.
If the parameter is null or contains an empty list, meaning no value has been set for the parameter,
the entire $X{} clause is evaluated as the always true statement “0 = 0”.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment