Home
Analytics
Unable to pass $ symbol as report parameter !!!
Devidas
Hi Guys,<br />
<br />
I am designing a report using BIRT. I have some place holders in my query (for filter criteria) and I am dynamically replacing this query using the script in the beforeOpen() method based on some reporting parameter values <br />
<br />
The script would be some thing like this (I am passing comma delimited values as report parameters)<br />
<br />
var param1Length = params["param1"].value.length<br />
<br />
var filter = "";<br />
<br />
if ( param1Length > 0 )<br />
{<br />
filter = " AND DESCRIPTION IN ( "<br />
}<br />
<br />
for ( i=0; i < param1Length ; i++ )<br />
{<br />
if( i == 0 )<br />
{<br />
filter = filter + params["param1"].value
;<br />
} <br />
else <br />
{<br />
filter = filter + " , " + params["param1"].value
;<br />
}<br />
}<br />
<br />
if ( param1Length > 0 )<br />
{<br />
filter = filter + " ) ";<br />
}<br />
<br />
<br />
this.queryText = this.queryText.replaceAll("filter ",filter );<br />
<br />
The replacement work fine and the report runs when I pass string values that doesn't contain $ characer.<br />
<br />
When the report parameter contains $ value I am getting exception stack trace as follows<br />
<br />
org.eclipse.birt.core.script.ScriptContext.eval(ScriptContext.java:268) at org.eclipse.birt.data.engine.script.ScriptEvalUtil.evaluateJSAsExpr(ScriptEvalUtil.java:713) ... 114 more Caused by: org.mozilla.javascript.WrappedException: Wrapped java.lang.IndexOutOfBoundsException: No group 5 (<inline>#51) at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1757) at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:170) at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243) at org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76) at org.mozilla.javascript.gen.c4._c1(<inline>:51) at org.mozilla.javascript.gen.c4.call(<inline>) at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108) at org.mozilla.javascript.gen.c5._c0(<inline>:1) at org.mozilla.javascript.gen.c5.call(<inline>) at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)...........<br />
<br />
It would be a great help if some one could come up with a solution. <br />
<br />
Thanks in advance<br />
Devidas
Find more posts tagged with
Comments
bhanley
The dollar sign is a special character within the BIRT query parser. It is used to handle dynamic parameter substitution. The use of a dollar sign allows you to then edit the data set and bind a value (usually a run-time parameter) to be swapped in before the query is executed. I do not know what your requirements are, but perhaps that will alleviate your need for a script on the <strong class='bbc'><em class='bbc'>beforeOpen </em></strong>event??<br />
<br />
If the scripting layer is the way you need to go, are you enclosing the dollar sign in single quotes? (<em class='bbc'>'$'</em>) This should protect it from the parser.
Devidas
Hi Bhanley,
Thanks for the information.
Suri
bhanley,
could you post an example of how to use the $ (dollar) sign in queries or indicate any documentation about it? I think it would solve many of my problems with parameters, but I had no success using it (I tried substituting the ? sign in my query but it failed...).
Thanks!