I need to pass parameters (variables) in to my report template when running a report. How do I do this? I am using the Java version of Windward.
You pass the parameters in by attaching them to each datasource. You can set a different set of parameters and values for each datasource.
You do this by creating a java.util.Map that contains the parameters. The key is a String with the variable name. The value can be a String, Number, or Date. The value type should match database column types if the variable will be used as a parameter in a select.
These are set in the datasource by calling DataSourceProvider.setMap(). Dom4jDataSource and JdbcDataSource both implement DataSourceProvider.
DataSourceProvider datasource = new JdbcDataSource("com.microsoft.sqlserver.jdbc.SQLServerDriver", "jdbc:sqlserver://localhost:1433;DatabaseName=Northwind", "username, "password");
Map map = new HashMap();
map.put("now", new Date());
datasource.setMap(map);
Note that variables are carried across datasources if multiple datasources are applied to a template. If a variable is set in the first datasource, and is not set in the second, it will retain its value from the first. If it is set in the second, that will override the saved value.