You have two options for defining the parameters of a data source, such as the host and port number:
| • | Define the parameters statically, so that they are the same for every user. |
| • | Have the server derive these parameters at run time 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 on how to create attributes, see Managing Attributes.
When referring to an attribute in a data source definition, you can specify the attribute categorically or 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 reports using this data source will fail with an error. You can specify these attribute categories: |
| • | User – In the attributes defined on 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 server level. If the specified attribute is not found in either of these, the reports using this data source will fail 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','Server')} - Port will be derived from the server-level attributes. |
| • | {attribute('db','Server')} - Database name 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 server-level attributes. |
| • | {attribute('password')} - The password field can also reference an attribute, here a hierarchical attribute. |
For information about attributes on users and the server, see Managing Attributes.
Recommended Comments
There are no comments to display.