根据birt报告中的参数删除图表

时间:2014-02-22 06:38:07

标签: parameters charts birt

在这里我提出了两个问题 1)我有两个数据集,两个图表和两个参数所以现在我试图根据参数删除图表例如::如果我选择参数[“地理”]。值第二个图表必须下降,如果我选择参数[ “出口”]。价值第一个图表必须下降所以我在工厂之前写了脚本但是它的工作没有任何错误

outname = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("out");
geoname = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("geo");

if (params["Geography"].value)
{
outname.drop();
}
else
{
geoname.drop();
}

2)在选择传递给图表的参数值时,但有时候会出现错误,如何检查并停止此错误

The following items have errors:

Chart (id = 2736):
- TypeError: Cannot call method "getSeriesIdentifier" of null at line 43 of chart script:''
exception.javascript.error ( 1 time(s) )
detail : org.eclipse.birt.report.engine.api.EngineException: TypeError: Cannot call method "getSeriesIdentifier" of null at line 43 of chart script:''
    at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1245)
    at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.processExtendedContent(LocalizedContentVisitor.java:1097)
    at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localizeForeign(LocalizedContentVisitor.java:591)
    at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.localize(LocalizedContentVisitor.java:176)
    at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:37)
    at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layoutNodes(HTMLBlockStackingLM.java:65)
    at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPageLM.java:92)
    at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.layout(HTMLReportLayoutEngine.java:100)
    at org.eclipse.birt.report.engine.api.impl.RenderTask$PageRangeRender.render(RenderTask.java:718)
    at org.eclipse.birt.report.engine.api.impl.RenderTask.render(RenderTask.java:321)
    at org.eclipse.birt.report.service.ReportEngineService.renderReport(ReportEngineService.java:1555)
    at org.eclipse.birt.report.service.BirtViewerReportService.getPage(BirtViewerReportService.java:204)
    at org.eclipse.birt.report.service.actionhandler.BirtChangeParameterActionHandler.doRenderPage(BirtChangeParameterActionHandler.java:82)
    at org.eclipse.birt.report.service.actionhandler.AbstractChangeParameterActionHandler.__execute(AbstractChangeParameterActionHandler.java:102)
    at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandler.execute(AbstractBaseActionHandler.java:90)
    at org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProcessor.__executeAction(AbstractBaseDocumentProcessor.java:47)
    at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.executeAction(AbstractBaseComponentProcessor.java:143)
    at org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.handleChangeParameter(BirtDocumentProcessor.java:100)
    at sun.reflect.GeneratedMethodAccessor194.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentProcessor.process(AbstractBaseComponentProcessor.java:112)
    at org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUpdatedObjects(BirtSoapBindingImpl.java:66)
    at sun.reflect.GeneratedMethodAccessor136.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.java:397)
    at org.apache.axis.providers.java.RPCProvider.processMessage(RPCProvider.java:186)
    at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323)
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
    at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
    at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
    at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
    at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPost(BirtSoapMessageDispatcherServlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
    at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.service(BirtSoapMessageDispatcherServlet.java:122)
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:128)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
    at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:386)
    at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:669)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:457)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:229)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1075)
    at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:384)
    at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1009)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
    at org.eclipse.jetty.server.Server.handle(Server.java:368)
    at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
    at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:953)
    at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1014)
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:861)
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:628)
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
    at java.lang.Thread.run(Thread.java:724)
Caused by: org.eclipse.birt.chart.exception.ChartException: TypeError: Cannot call method "getSeriesIdentifier" of null at line 43 of chart script:''
    at org.eclipse.birt.chart.script.AbstractScriptHandler.convertException(AbstractScriptHandler.java:738)
    at org.eclipse.birt.chart.script.AbstractScriptHandler.callJavaScriptFunction(AbstractScriptHandler.java:374)
    at org.eclipse.birt.chart.script.AbstractScriptHandler.callFunction(AbstractScriptHandler.java:558)
    at org.eclipse.birt.chart.render.AxesRenderer.renderPlot(AxesRenderer.java:2308)
    at org.eclipse.birt.chart.render.AxesRenderer.render(AxesRenderer.java:229)
    at org.eclipse.birt.chart.factory.Generator.render(Generator.java:1382)
    at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationBase.renderToImageFile(ChartReportItemPresentationBase.java:1128)
    at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationBase.generateRenderObject(ChartReportItemPresentationBase.java:979)
    at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationBase.onRowSets(ChartReportItemPresentationBase.java:904)
    at org.eclipse.birt.chart.reportitem.ChartReportItemPresentationProxy.onRowSets(ChartReportItemPresentationProxy.java:108)
    at org.eclipse.birt.report.engine.presentation.LocalizedContentVisitor.processExtendedContent(LocalizedContentVisitor.java:1074)
    ... 65 more
Caused by: org.mozilla.javascript.EcmaError: TypeError: Cannot call method "getSeriesIdentifier" of null (/report/body/extended-item[@id="2736"]/method[@name="onRender"]#43)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3654)
    at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3632)
    at org.mozilla.javascript.ScriptRuntime.typeError(ScriptRuntime.java:3660)
    at org.mozilla.javascript.ScriptRuntime.typeError2(ScriptRuntime.java:3679)
    at org.mozilla.javascript.ScriptRuntime.undefCallError(ScriptRuntime.java:3698)
    at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThisHelper(ScriptRuntime.java:2221)
    at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRuntime.java:2214)
    at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:117)
    at org.mozilla.javascript.gen.c980._c2(/report/body/extended-item[@id="2736"]/method[@name="onRender"]:43)
    at org.mozilla.javascript.gen.c980.call(/report/body/extended-item[@id="2736"]/method[@name="onRender"])
    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
    at org.mozilla.javascript.gen.c980.call(/report/body/extended-item[@id="2736"]/method[@name="onRender"])
    at org.eclipse.birt.chart.script.AbstractScriptHandler.callJavaScriptFunction(AbstractScriptHandler.java:370)
    ... 74 more

1 个答案:

答案 0 :(得分:0)

1)beforeFactory中的脚本没问题,异常与它无关。由于以下原因之一,您的图表未正确删除:

您的设计中未设置1个名称“out”和“geo”

2 - 您的参数Geography不是布尔数据类型。可能是你忘了测试一个值,比如:

if (params["Geography"].value=="geo")
{
outname.drop();
}
else
{
geoname.drop();
}

2)附加到图表的一些javascript代码中会出现错误:

在Eclipse设计器中选择chart =>脚本选项卡,在第43行,您应该看到调用“getSeriesIdentifier”方法的代码。

最有可能的是,根据您的输入参数,图表有时不返回任何数据,因此未定义调用getSeriesIdentifier的对象。

要解决此问题,请在使用前检查此对象是否为!=