Attributes in Data Source Definitions

You have two options for defining the parameters of a data source. You can either:

Specifically define the parameters, like host, port, and database.
Have the server derive these parameters at runtime based on attributes you provide.

Attributes can be used to derive all data source parameters that are not selected from drop down lists. For instructions to define attributes, see Managing Attributes.

When defining a data source attribute, you can either specify the category in which the server should look for its value, or allow the server to locate the value hierarchically.

Categorical reference – If you specify a category for the attribute value, the server attempts to find that particular value of the attribute. If the attribute is not defined where specified, the report fails with an error. You can specify these attribute categories:
     User – In the attributes defined on the logged-in user.
     Tenant – In the attributes defined on the organization of the logged-in user.
     Server – In the attributes defined at the server-level.
Hierarchical reference – If you don't specify a category for the attribute, the server searches attributes hierarchically and uses the value of the first attribute it finds with the given name. This search starts with the logged in user, then proceeds to the user's organization and parent organizations, and finally to the server level. If the specified attribute is not found, the report fails with an error.

The following figure is an example of attributes used to define data source parameters.

Using Attributes for Data Source Parameters

In the example above, the following data source parameters are specified by attributes:

{attribute('host','User')} - Host will be derived categorically from the logged-in user's attributes, because the "User" category is specified.
{attribute('port','Tenant')} - Port will be derived from the logged in user's organization attributes.
{attribute('db','Server')} - Database will be derived from the server-level attributes.
The URL is generated automatically from the host, port, and database fields.
{attribute('userName')} - The user name will be derived hierarchically, because no category is specified. JasperReports Server will look for a host first in the logged in user's attributes, then in the organization attributes, and finally the server-level attributes.
{attribute('password')} - The password field can also reference an attribute, here a hierarchical attribute.

For information about attributes on users, organization, and the server, see Managing Attributes.

Version: 
Feedback
randomness