@ -8,5 +8,261 @@ If the project runs based on tomcat, there will be no directory of “ureportfil
Start running the project created, open the report designer, click the save button on the toolbar and select “save”. Then we can see the pop-up window as shown in the figure below:![](docs/images/save-dialog.png)
![](docs/images/save-dialog.png)![](/docs/images/save-dialog.png)We only need to input the name of the report and select the storage directory of the report in this window to save the current report file. We can see that the default storage location of UReport2 is the “server file system”, i.e. the “ureportfiles” directory under WEB-INF directory of our project.
This directory is automatically generated by the system by default. We may change the location of the directory by adding an attribute if needed.
Create a file config.properties under the WEB-INF directory of the project, open the spring configuration file named context.xml under WEB-INF and add the following Bean to load the file config.properties.
**Note: **The above Bean configuraton is practically a standard configuration of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer class. We know that we can load external properties of Spring by configuring PropertyPlaceholderConfigurer. If the project has been configured with PropertyPlaceholderConfigurer class, the corresponding UReport2 properties can be directly added to the properties file corresponding to the class of the configuration, and it is no need to configure the config.properties file.
Open the file config.properties and add the attribute named “ureport.fileStoreDir”, while the value of the attribute is applied to define the default file system-based report storage directory provided by UReport2. For example, the attribute can be defined as follows:
```
ureport.fileStoreDir=D:/ureportfiles
```
It means to save the report files in the directory ureportfiles under the Drive D. It shall be noted that when the specific directory is assigned, we shall save the directory and assure its existence, otherwise it will not be adopted. For an instance, the directory named ureportfiles in Drive D must exist and needs to be created in advance.
The report storage mechanism known as the “server file system” provided by UReport2 by fault actually realizes the interface of com.bstek.ureport.provider.report.Report Provider provided by UReport2. The source code of the interface is as follows:
* Load the report file according to the report name
*@param file 报表名称
* @param file report name
*@return 返回的InputStream
* @return returned InputStream
*/
InputStream loadReport(String file);
/**
* 根据报表名,删除指定的报表文件
* Delete the specific report file according to the report name
* @param file 报表名称
* @param file report name
*/
void deleteReport(String file);
/**
* 获取所有的报表文件
* Acquire all report files
* @return 返回报表文件列表
* @return return the list of report file
*/
List<ReportFile> getReportFiles();
/**
* 保存报表文件
* Save report files
*@param file 报表名称
* @param file report name
*@param content 报表的XML内容
* @param content XML content of report
*/
void saveReport(String file,String content);
/**
* @return 返回存储器名称
* @return return storage name
*/
String getName();
/**
* @return 返回是否禁用
* @return return if deactivation
*/
boolean disabled();
/**
* @return 返回报表文件名前缀
* @return return prefix of report name
*/
String getPrefix();
}
```
After realizing the ReportProvider interface, configure the implementation class to Spring and make it a standard Spring Bean. Then UReport2 will detect, find and load it. The source code of the report storage known as the “server file system” provided by UReport2 by default is listed below:
Disable the default report storage provided by the system. If we customize the report storage and do not want to use the default report storage of “server file system” provided by the system, we only needs to add an attribute named ureport.disableFileProvider in the config.properties file mentioned above and set its value as true.
In view of the introduction above, we can easily develop other types of report storages by realizing the ReportProvider interface, such as developing a new report storage to save reports in database and FTP etc.
# The data source Configuration
Open the report designer in UReport2. We can see three types of data sources of reports provided by UReport2, as shown in the figure below: