Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » params["dt1"].setHours(23,59,59,999); return error?!!
params["dt1"].setHours(23,59,59,999); return error?!! [message #694009] Thu, 07 July 2011 16:11 Go to next message
tong123123 tong123123 is currently offline tong123123 tong123123Friend
Messages: 74
Registered: April 2011
Member
I have a report parameter "dt1" and datatype set to datetime,
in a dataset beforeOpen event, I write the following
if (params["dt1"] == null){
	Packages.java.lang.System.out.println("parameter is null");
} else{
	Packages.java.lang.System.out.println("parameter is not null");
	params["dt1"].setHours(23,59,59,999);
	Packages.java.lang.System.out.println("see?");
}
Packages.java.lang.System.out.println(params["dt1"]);

and I check the output in eclipsec.exe and see the following error
Quote:

parameter is not null
2011/7/8 上午 12:04:35 org.eclipse.birt.report.engine.script.internal.DtEScriptE
xecutor handleJS
警告: null
java.lang.NullPointerException
at org.eclipse.birt.report.engine.executor.ScriptableParameter.get(Scrip
tableParameter.java:64)
at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.
java:1263)
at org.mozilla.javascript.ScriptRuntime.getPropFunctionAndThis(ScriptRun
time.java:1971)
at org.mozilla.javascript.gen.c73._c1(DataSet[contract_current_salary]._
_bm_beforeOpen:13)
at org.mozilla.javascript.gen.c73.call(DataSet[contract_current_salary].
__bm_beforeOpen)
at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java
:105)
at org.mozilla.javascript.gen.c36._c0(DataSet[contract_current_salary]._
_bm_beforeOpen:1)
at org.mozilla.javascript.gen.c36.call(DataSet[contract_current_salary].
__bm_beforeOpen)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:3
04)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:276
9)
at org.mozilla.javascript.gen.c36.call(DataSet[contract_current_salary].
__bm_beforeOpen)
at org.mozilla.javascript.gen.c36.exec(DataSet[contract_current_salary].
__bm_beforeOpen)
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateRawScript(Jav
ascriptEvalUtil.java:95)
at org.eclipse.birt.core.script.JavascriptEvalUtil.evaluateScript(Javasc
riptEvalUtil.java:134)
at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(S
criptEvalUtil.java:676)
at org.eclipse.birt.data.engine.script.JSMethodRunner.runScript(JSMethod
Runner.java:79)
at org.eclipse.birt.report.engine.script.internal.DtEScriptExecutor.hand
leJS(DtEScriptExecutor.java:71)
at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.
handleJS(DataSetScriptExecutor.java:159)
at org.eclipse.birt.report.engine.script.internal.DataSetScriptExecutor.
handleBeforeOpen(DataSetScriptExecutor.java:64)
at org.eclipse.birt.data.engine.impl.DataSetRuntime.beforeOpen(DataSetRu
ntime.java:503)
at org.eclipse.birt.data.engine.impl.QueryExecutor.prepareExecution(Quer
yExecutor.java:213)
at org.eclipse.birt.data.engine.impl.PreparedQuery.doPrepare(PreparedQue
ry.java:500)
at org.eclipse.birt.data.engine.impl.PreparedDataSourceQuery.execute(Pre
paredDataSourceQuery.java:161)
at org.eclipse.birt.data.engine.impl.PreparedOdaDSQuery.execute(Prepared
OdaDSQuery.java:142)
at org.eclipse.birt.report.data.adapter.impl.DataRequestSessionImpl.exec
ute(DataRequestSessionImpl.java:438)
at org.eclipse.birt.report.engine.data.dte.DataGenerationEngine.doExecut
eQuery(DataGenerationEngine.java:149)
at org.eclipse.birt.report.engine.data.dte.DataGenerationEngine.doExecut
eQuery(DataGenerationEngine.java:111)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.execute(Ab
stractDataEngine.java:182)
at org.eclipse.birt.report.engine.executor.ExecutionContext.executeQuery
(ExecutionContext.java:1683)
at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuer
y(QueryItemExecutor.java:76)
at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(Tab
leItemExecutor.java:61)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportIt
emExecutor.execute(WrappedReportItemExecutor.java:45)
at org.eclipse.birt.report.engine.internal.executor.emitter.ReportItemEm
itterExecutor.execute(ReportItemEmitterExecutor.java:45)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicat
eItemExecutor.execute(SuppressDuplicateItemExecutor.java:42)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layout
Nodes(HTMLBlockStackingLM.java:63)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChild
ren(HTMLStackingLM.java:27)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTML
AbstractLM.java:133)
at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.resum
eLayout(HTMLInlineStackingLM.java:95)
at org.eclipse.birt.report.engine.layout.html.HTMLInlineStackingLM.layou
tNodes(HTMLInlineStackingLM.java:135)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChild
ren(HTMLStackingLM.java:27)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTML
AbstractLM.java:133)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layout
Nodes(HTMLBlockStackingLM.java:68)
at org.eclipse.birt.report.engine.layout.html.HTMLStackingLM.layoutChild
ren(HTMLStackingLM.java:27)
at org.eclipse.birt.report.engine.layout.html.HTMLTableLM.layoutChildren
(HTMLTableLM.java:76)
at org.eclipse.birt.report.engine.layout.html.HTMLAbstractLM.layout(HTML
AbstractLM.java:133)
at org.eclipse.birt.report.engine.layout.html.HTMLBlockStackingLM.layout
Nodes(HTMLBlockStackingLM.java:68)
at org.eclipse.birt.report.engine.layout.html.HTMLPageLM.layout(HTMLPage
LM.java:85)
at org.eclipse.birt.report.engine.layout.html.HTMLReportLayoutEngine.lay
out(HTMLReportLayoutEngine.java:106)
at org.eclipse.birt.report.engine.presentation.ReportDocumentBuilder.bui
ld(ReportDocumentBuilder.java:189)
at org.eclipse.birt.report.engine.api.impl.RunTask.doRun(RunTask.java:22
4)
at org.eclipse.birt.report.engine.api.impl.RunTask.run(RunTask.java:89)
at org.eclipse.birt.report.service.ReportEngineService.runReport(Unknown
Source)
at org.eclipse.birt.report.service.BirtViewerReportService.runReport(Unk
nown Source)
at org.eclipse.birt.report.service.actionhandler.BirtRunReportActionHand
ler.__execute(Unknown Source)
at org.eclipse.birt.report.service.actionhandler.BirtChangeParameterActi
onHandler.runReport(Unknown Source)
at org.eclipse.birt.report.service.actionhandler.AbstractChangeParameter
ActionHandler.__execute(Unknown Source)
at org.eclipse.birt.report.service.actionhandler.AbstractBaseActionHandl
er.execute(Unknown Source)
at org.eclipse.birt.report.soapengine.processor.AbstractBaseDocumentProc
essor.__executeAction(Unknown Source)
at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentPro
cessor.executeAction(Unknown Source)
at org.eclipse.birt.report.soapengine.processor.BirtDocumentProcessor.ha
ndleChangeParameter(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.birt.report.soapengine.processor.AbstractBaseComponentPro
cessor.process(Unknown Source)
at org.eclipse.birt.report.soapengine.endpoint.BirtSoapBindingImpl.getUp
datedObjects(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis.providers.java.RPCProvider.invokeMethod(RPCProvider.j
ava: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(InvocationStrateg
y.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:453
)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:69
9)
at org.eclipse.birt.report.servlet.BirtSoapMessageDispatcherServlet.doPo
st(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBas
e.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at org.eclipse.birt.report.filter.ViewerFilter.doFilter(Unknown Source)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:213)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve
.java:246)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:
2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatche
rValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
at org.eclipse.tomcat.internal.EclipseErrorReportValve.invoke(EclipseErr
orReportValve.java:153)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContex
t.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:19
9)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Unknown Source)


from the quoted, it is obivous that params["dt1"] is not null, but why when I run
params["dt1"].setHours(23,59,59,999);
it throws
Quote:

2011/7/8 上午 12:04:35 org.eclipse.birt.report.engine.script.internal.DtEScriptE
xecutor handleJS
警告: null
java.lang.NullPointerException
at org.eclipse.birt.report.engine.executor.ScriptableParameter.get(Scrip
tableParameter.java:64)
???

I am using birt version 2.2.1

[Updated on: Thu, 07 July 2011 16:31]

Report message to a moderator

Re: params["dt1"].setHours(23,59,59,999); return error?!! [message #694028 is a reply to message #694009] Thu, 07 July 2011 16:46 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1687
Registered: July 2009
Senior Member

So, if you run this without the ".setHours(23,59,59,999)", it runs without issue?

Regards,

Michael

BIRT Evangelist on
http://www.birt-exchange.org


Michael

Add interactivity, scheduling, sharing, live Excel export, and JS integration to your BIRT app with the new, free BIRT server, BIRT iHub F-Type.
Re: params["dt1"].setHours(23,59,59,999); return error?!! [message #694037 is a reply to message #694028] Thu, 07 July 2011 17:02 Go to previous messageGo to next message
tong123123 tong123123 is currently offline tong123123 tong123123Friend
Messages: 74
Registered: April 2011
Member
I found I need to write something like the following
if (params["dt1"] == null){
	Packages.java.lang.System.out.println("parameter is null");
} else{
	Packages.java.lang.System.out.println("parameter is not null");
	var dt = Date.parse(params["dt1"]);
	Packages.java.lang.System.out.println("dt = " + dt);
	var jsDt = new Date(dt);
	Packages.java.lang.System.out.println("jsDt = " + jsDt);
	jsDt.setHours(23,59,59,999);
	Packages.java.lang.System.out.println("jsDt = " + jsDt);
	/*
	try{
		params["dt1"].getClass();
	}catch(ex){
		Packages.java.lang.System.out.println("error in getClass()" + ex);
	}
	Packages.java.lang.System.out.println(getClass(params["dt1"]));
	try{
		params["dt1"].setHours(23,59,59,999);
	}catch(ex){
		Packages.java.lang.System.out.println("exception" + ex);
	}*/
	Packages.java.lang.System.out.println("see?");
}
Packages.java.lang.System.out.println(params["dt1"]);


then no exception is thrown.
in eclipsec.exe, it show
Quote:

parameter is not null
dt = 1309845600000
jsDt = Tue Jul 05 2011 14:00:00 GMT+0800 (CST)
jsDt = Tue Jul 05 2011 23:59:59 GMT+0800 (CST)
see?
Tue Jul 05 00:00:00 CST 2011


Anyway, I really don't know why need to write something like
var dt = Date.parse(params["dt1"]);
var jsDt = new Date(dt);
jsDt.setHours(23,59,59,999);


if params["dt1"] is not in javascript Date object type but in java.util.Date class, then why
params["dt1"].getClass();

will throws exception!! in java, Object.getClass() is valid!!

I am using birt designer 2.2.1

[Updated on: Thu, 07 July 2011 17:03]

Report message to a moderator

(no subject) [message #694440 is a reply to message #694037] Fri, 08 July 2011 15:34 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

What version of BIRT are you using? I just tried this with 2.6.1 and it
returns the class. Create a blank report, add a date/datetime
parameter, in the before factory script add the following:

aaa = params["mydate"].getClass();

Add a data item to the report and set its expression to aaa and set its
type to a string.

Jason

On 7/7/2011 1:02 PM, forums-noreply@eclipse.org wrote:
> I found I need to write something like the following
>
> if (params["dt1"] == null){
> Packages.java.lang.System.out.println("parameter is null");
> } else{
> Packages.java.lang.System.out.println("parameter is not null");
> var dt = Date.parse(params["dt1"]);
> Packages.java.lang.System.out.println("dt = " + dt);
> var jsDt = new Date(dt);
> Packages.java.lang.System.out.println("jsDt = " + jsDt);
> jsDt.setHours(23,59,59,999);
> Packages.java.lang.System.out.println("jsDt = " + jsDt);
> /*
> try{
> params["dt1"].getClass();
> }catch(ex){
> Packages.java.lang.System.out.println("error in getClass()" + ex);
> }
> Packages.java.lang.System.out.println(getClass(params["dt1"]));
> try{
> params["dt1"].setHours(23,59,59,999);
> }catch(ex){
> Packages.java.lang.System.out.println("exception" + ex);
> }*/
> Packages.java.lang.System.out.println("see?");
> }
> Packages.java.lang.System.out.println(params["dt1"]);
>
>
> then no exception is thrown.
> in eclipsec.exe, it show
> Quote:
>> parameter is not null
>> dt = 1309845600000
>> jsDt = Tue Jul 05 2011 14:00:00 GMT+0800 (CST)
>> jsDt = Tue Jul 05 2011 23:59:59 GMT+0800 (CST)
>> see?
>> Tue Jul 05 00:00:00 CST 2011
>
>
> Anyway, I really don't know why need to write something like
>
> var dt = Date.parse(params["dt1"]);
> var jsDt = new Date(dt);
> jsDt.setHours(23,59,59,999);
>
>
> if params["dt1"] is not in javascript Date object type but in
> java.util.Date class, then why
>
> params["dt1"].getClass();
>
> will throws exception!! in java, Object.getClass() is valid!!
Re: (no subject) [message #694480 is a reply to message #694440] Fri, 08 July 2011 17:30 Go to previous messageGo to next message
tong123123 tong123123 is currently offline tong123123 tong123123Friend
Messages: 74
Registered: April 2011
Member
I use birt report 2.2.1
but could you run
params["mydate"].setHours(23,59,59,999);
successfully?

as quoted from my first post, it throws
Quote:

parameter is not null
2011/7/8 上午 12:04:35 org.eclipse.birt.report.engine.script.internal.DtEScriptE
xecutor handleJS
警告: null
java.lang.NullPointerException
at org.eclipse.birt.report.engine.executor.ScriptableParameter.get(Scrip
tableParameter.java:64)


(no subject) [message #694486 is a reply to message #694440] Fri, 08 July 2011 17:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: <forums-noreply

I use birt report 2.2.1
but could you run
params["mydate"].setHours(23,59,59,999);
successfully?

as quoted from my first post, it throws
Quote:
> parameter is not null
> 2011/7/8 上午 12:04:35 org.eclipse.birt.report.engine.script.internal.DtEScriptE
> xecutor handleJS
> 警告: null
> java.lang.NullPointerException
> at org.eclipse.birt.report.engine.executor.ScriptableParameter.get(Scrip
> tableParameter.java:64)
Re: (no subject) [message #694489 is a reply to message #694480] Fri, 08 July 2011 17:41 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I think setHours is deprecated so I did it like:
aaa = params["mydate"].getClass();
importPackage(Packages.java.util);
cal = new GregorianCalendar();
cal.setTime(params["mydate"]);
cal.set(Calendar.HOUR_OF_DAY, 10);
cal.set(Calendar.MINUTE, 11);
cal.set(Calendar.SECOND, 12);
cal.set(Calendar.MILLISECOND, 0);
params["mydate"] = cal.getTime();

Jason

On 7/8/2011 1:30 PM, forums-noreply@eclipse.org wrote:
> I use birt report 2.2.1
> but could you run params["mydate"].setHours(23,59,59,999);
> successfully?
>
> as quoted from my first post, it throws
> Quote:
>> parameter is not null
>> 2011/7/8 上午 12:04:35
>> org.eclipse.birt.report.engine.script.internal.DtEScriptE
>> xecutor handleJS
>> 警告: null
>> java.lang.NullPointerException
>> at org.eclipse.birt.report.engine.executor.ScriptableParameter.get(Scrip
>> tableParameter.java:64)
>
>
>
Previous Topic:How to use scriptContext class in Birt engine 2.6.1
Next Topic:Birt is great but how about ability to set OutputStream in IRunAndRenderTask for the chart images
Goto Forum:
  


Current Time: Mon Dec 22 00:51:56 GMT 2014

Powered by FUDForum. Page generated in 0.08947 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software