cuba-platform / reports

CUBA Reports Addon
https://www.cuba-platform.com/
Apache License 2.0
9 stars 4 forks source link

When using the "Reports list actions" (listPrintForm) the "Print All" options fails with a ViewNotFoundException #265

Closed joelbohnes closed 4 years ago

joelbohnes commented 4 years ago

Environment

Description of the bug

When using the "Reports list actions" (listPrintForm), answering "Print All" on the confirmation prompt (occurs when selecting more than one entity to print) a ViewNotFoundException is thrown. The "Print selected" option works without any problems.

How to reproduce

  1. Create an entity
  2. Create a multi-select browser screen, use an internal view (i.e. <view extends="_local"/>)
  3. Add the listPrintForm action to the table (<action id="print" type="listPrintForm" />) and corresponding button.
  4. Add a report, use parameter type list of entities, reference the browser screen in the "Roles and Screens" section of the report.
  5. Open the browser screen, select at least two entries, print them. Select "Print All" when asked "Which data should be used for report?".

You may also use the attached demo project demo.zip.

Expected behavior

All entities are printed.

Actual behavior

com.haulmont.cuba.core.global.ViewNotFoundException: View factura_IbanStructure/ not found
    at com.haulmont.cuba.core.sys.AbstractViewRepository.getView(AbstractViewRepository.java:184) ~[cuba-global-7.2.7.jar:7.2.7]
    at com.haulmont.reports.PrototypesLoader.loadData(PrototypesLoader.java:39) ~[reports-core-7.2.7.jar:7.2.7]
    at com.haulmont.reports.ReportingBean.loadDataForParameterPrototype(ReportingBean.java:420) ~[reports-core-7.2.7.jar:7.2.7]
    at com.haulmont.reports.ReportingBean.createReportDocumentInternal(ReportingBean.java:370) ~[reports-core-7.2.7.jar:7.2.7]
    at com.haulmont.reports.ReportingBean.createReportDocument(ReportingBean.java:330) ~[reports-core-7.2.7.jar:7.2.7]
    at com.haulmont.reports.ReportingBean.createReport(ReportingBean.java:214) ~[reports-core-7.2.7.jar:7.2.7]
    at com.haulmont.reports.ReportServiceBean.createReport(ReportServiceBean.java:46) ~[reports-core-7.2.7.jar:7.2.7]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:88) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:90) ~[cuba-core-7.2.7.jar:7.2.7]
    at jdk.internal.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:644) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:633) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:95) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) ~[spring-aop-5.2.3.RELEASE.jar:5.2.3.RELEASE]
    at com.sun.proxy.$Proxy273.createReport(Unknown Source) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at com.haulmont.cuba.core.sys.remoting.LocalServiceInvokerImpl.invoke(LocalServiceInvokerImpl.java:94) ~[cuba-core-7.2.7.jar:7.2.7]
    at com.haulmont.cuba.web.sys.remoting.LocalServiceProxy$LocalServiceInvocationHandler.invoke(LocalServiceProxy.java:159) ~[na:na]
    at com.sun.proxy.$Proxy67.createReport(Unknown Source) ~[na:na]
    at com.haulmont.reports.gui.ReportGuiManager.getReportResult(ReportGuiManager.java:286) ~[na:na]
    at com.haulmont.reports.gui.ReportGuiManager.printReportSync(ReportGuiManager.java:257) ~[na:na]
    at com.haulmont.reports.gui.ReportGuiManager.printReport(ReportGuiManager.java:226) ~[na:na]
    at com.haulmont.reports.gui.ReportGuiManager.printReport(ReportGuiManager.java:204) ~[na:na]
    at com.haulmont.reports.gui.ReportGuiManager.runReport(ReportGuiManager.java:155) ~[na:na]
    at com.haulmont.reports.gui.actions.AbstractPrintFormAction.openRunReportScreen(AbstractPrintFormAction.java:90) ~[na:na]
    at com.haulmont.reports.gui.actions.AbstractPrintFormAction.openRunReportScreen(AbstractPrintFormAction.java:56) ~[na:na]
    at com.haulmont.reports.gui.actions.list.ListPrintFormAction.printAll(ListPrintFormAction.java:222) ~[na:na]
    at com.haulmont.reports.gui.actions.list.ListPrintFormAction$2.actionPerform(ListPrintFormAction.java:121) ~[na:na]
    at com.haulmont.cuba.web.sys.WebDialogs$OptionDialogBuilderImpl.lambda$show$0(WebDialogs.java:360) ~[na:na]
    at com.haulmont.cuba.web.widgets.CubaButton.fireClick(CubaButton.java:76) ~[na:na]

Workaround

The reports module requires a named view when using "Print All". Simple workaround is to not use internal views: 1) Create a named view (i.e. myEntity-list) 2) In the screen xml of the browser window: add the named view to the collection node (window > data > collection), i.e. <collection ... view="myEntity-list">...</collection>

Analysis

View name is copied in ListPrintFormAction.java. View name is empty if an "internal view" is used.

The missing view name causes an exception later inside PrototypesLoader.java.