Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
API automatically creates broken binding
MitchMove
Hey All,<br />
<br />
I have been working generating my own reports for a while.<br />
I've got everything set up, there is only one problem remaining.<br />
<br />
I have got a binding that i want to use in a hide expression, but when i add the hiderule, the api seems to automatically generate a new binding for my binding, and it assumes my initial binding is a dataset member.<br />
<br />
I have a lot of other bindings already working, so I assume there is no problem there.<br />
<br />
I use the following code to generate the hide expression.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
public void hideElement(DesignElementHandle handle, String expression) throws SemanticException {
if (handle == null || expression == null) return;
HideRule hr = StructureFactory.createHideRule();
PropertyHandle ph = handle.getPropertyHandle(IReportItemModel.VISIBILITY_PROP);
if (ph != null) {
ph.clearValue();
HideRuleHandle hrHandle = (HideRuleHandle) ph.addItem(hr);
hrHandle.setFormat(DesignChoiceConstants.FORMAT_TYPE_ALL);
//hrHandle.setProperty(HideRule.VALUE_EXPR_MEMBER, expression);
hrHandle.setExpressionProperty(HideRule.VALUE_EXPR_MEMBER, new Expression(expression, "javascript"));
}
}
</pre>
<br />
which results in the following xml entry, which looks great (I use it to hide a label)<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<label name="element128" id="573">
<list-property name="visibility">
<structure>
<property name="format">all</property>
<expression name="valueExpr" type="javascript">row["element127"]==null</expression>
</structure>
</list-property>
<text-property name="text" key="allReports.type.DRIVE_STOP">allReports.type.DRIVE_STOP</text-property>
</label>
</pre>
<br />
And now the weird part, this seems to come out of nowhere<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<structure>
<property name="name">element127_1</property>
<expression name="expression">dataSetRow["element127"]</expression>
<simple-property-list name="aggregateOn">
<value>unitGroup</value>
</simple-property-list>
</structure>
</pre>
<br />
As you see, my hide expression is "row["element127"]==null" and somehow, the API sees the "element127", when I add my hiderule, creates a binding for it, and refers to my binding using "dataSetRow" ... Why does it do that ?<br />
<br />
Because of that, i get the following error:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
org.eclipse.birt.report.engine.api.EngineException: Column binding "element127_1" has referred to a data set column "element127" which does not exist. (Element ID:10)
</pre>
<br />
Edit:<br />
Useful to know maybe, the automatically generated binding looks a lot like the binding it refers to<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<structure>
<property name="name">element127</property>
<expression name="expression">reportContext.getMessage("allReports.type.DRIVE_STOP")</expression>
<simple-property-list name="aggregateOn">
<value>unitGroup</value>
</simple-property-list>
<property name="aggregateFunction">count</property>
</structure>
</pre>
<br />
<br />
<br />
Can someone tell me why binding "element127_1" is created ? And how i can avoid it from being created ?<br />
<br />
Thank you very much !
Find more posts tagged with
Comments
kclark
Can you post the rest of the XML and the rest of the Java so I could try and run it?
MitchMove
kclark,<br />
<br />
Thank you very much for answering.<br />
I came up with a workaround for my problem.<br />
Instead of adding the addrule using the API, I now handle it by employing the "onprepare" script.<br />
I use the following lines that I found somewhere on the internet (sorry for not linking the source)<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
handle.setOnPrepare("{\n" +
"importPackage(Packages.org.eclipse.birt.report.model.api);\n" +
"importPackage(Packages.org.eclipse.birt.report.model.api.elements);\n" +
"var hr = StructureFactory.createHideRule();\n" +
"hr.setFormat(\"all\");\n" +
"hr.setExpression(\""+expression+"\");\n" +
"var ph = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement(this.name).getPropertyHandle(\"visibility\");\n" +
"if(ph!=null)ph.addItem(hr);} ");
</pre>
<br />
If you still want to see my code for debugging purposes, I will send you a pm.<br />
<br />
Regards
mariaux
<p>Hi, I am having exactly the same problem. It seems that every time I use the expression row["XXXX"] the API automatically creates the binding XXXXX -> dataSetRow["XXXXX"]. This is not correct in my case since XXXXX is not a data set column but a computed column or another column binding instead. </p><p> </p><p>Is there any way to solve this issue without having to resort to the onPrepare script? In my case this is not a suitable solution. </p><p> </p><p>Any help would be greatly appreciated. </p><p> </p><p>Maria </p>