0

我正在为基于 Grails 的 Web 应用程序使用 Jasper Reports,并且我有一个 ReportingContext.xml,其中包含每个报告的 bean,例如与报告模板 (jrxml) 的报告 ID/名称映射。我需要知道配置和设置上下文 xml 的基本步骤,以及如何在应用程序启动时将它们加载到我的报表控制器中。

旧应用程序位于使用此报告 xml 的 java/j2ee 中。我们必须在 grails 上开发一个类似的系统。

大多数上下文都包含用于报告名称映射的 jrxml,但我无法理解上下文中的某些 bean。

这是报告 context.xml 的示例内容,用于 1 个报告

 <beans> 
            <!-- ========================= REPORTING SERVICE WRAPPER ========================= -->
             <bean parent="baseTransactionProxy" name="myReportingService"> 
             <property name="proxyInterfaces" value="com.pack.my.reporting.service.myReportingService"/> 
             <property name="transactionAttributes">
                 <property name="target"> 
             <bean parent="baseServiceSupport" class="com.pack.my.reporting.service.impl.myReportingServiceImpl"> 
             <property name="reportManager" ref="reportManager"/> 
             <property name="mySecurityService" ref="mySecurityService"/> 
             <property name="businessUnitService" ref="businessUnitService"/> 
             </bean> 
             </property> 
             </bean> 
             <bean class="com.pack.my.reporting.manager.impl.ReportManagerImpl" id="reportManager"> 
             <property name="reportRenderers"> 
             <map> 
             <entry key="JasperPrint">
                 <entry key="siemJasperPrint">
             </map>
             </property>
             <property name="reportDefinitionDao" ref="reportDefinitionDao"/> 
             <property name="reportDao" ref="reportDao"/> 
             <property name="sequenceGeneratorService" ref="sequenceGeneratorService"/> 
             <property name="reportLocation" value="file:${my_HOME}/reports"/> 
             <property name="reportDefinitions">
                 <map> 
                 <entry key="businessUnitRoles"> 
                 <ref local="businessUnitRoles"/> 
                 </entry>
                 <entry key="businessUnitRoleUsers"> 
                 <ref local="businessUnitRoleUsers"/> 
                 </entry>
                 </map>
             </property>
             <property name="parameterPromptCodeMap">
                 <bean class="org.apache.commons.collections.map.CaseInsensitiveMap"> 
                 <constructor-arg> 
                 <map> 
                 <entry value="1" key="businessUnit"/> 
                 <entry value="1" key="businessUnitKey"/> 
                 <entry value="2" key="globaluser"/> 
                 <entry value="2" key="USERID"/> 
                 <entry value="2" key="USER_ID"/> 
                 <entry value="2" key="GLOBALUSERKEY"/> 
                 <entry value="3" key="identityCertification"/> 
                 <entry value="3" key="CERTIFICATIONID"/> 
                 <entry value="3" key="CERTIFICATION_ID"/> 
                 <entry value="4" key="startDate"/> 
                 </map> 
                 </constructor-arg> 
                 </bean> 
                 </property>
             </bean> 
            <!--- Report Groups Business Unit reports Group 1 Users reports -->
             <bean class="com.pack.my.reporting.domain.ReportDefinition" id="businessUnitRoles">
                 <property name="reportName" value="Business Unit Roles Report"/> 
                 <property name="reportFiles"> 
                 <map> 
                 <entry value="BusinessUnitRoles.jrxml" key="JasperPrint"/> 
                 </map> 
                 </property> 
                 <property name="promptForBusinessUnit" value="true"/> 
                 <property name="reportGroup" value="1"/> 
                 <property name="displayName" value="report.businessUnitRoles.name"/>
             <bean class="com.pack.my.reporting.domain.ReportDefinition" id="businessUnitUsers">

             </bean>
            </beans>
4

1 回答 1

1
  1. 将依赖项添加到 grails-app/conf/BuildConfig.groovy
  2. 将上述文件复制到/grails-app/conf/spring/resources.xml
  3. 阅读Grails 和 Spring - 参考文档

resources.xml 不再默认构建,因为 spring 目录中仅存在 resources.groovy。只需将您的 spring 上下文文件复制到 resources.xml 即可。

于 2011-10-12T23:28:00.163 回答