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)
Problem adding TOC expression on a group progammatically
pandersson
Hi all,<br />
<br />
I'm trying to programmatically add a TOC-expression to a group in a table which in the end should result in bookmarks in a pdf. When I use a static text in the toc-expression it works as expected but when I try to use a reference to row ( eg. row[column0] ) an exception is thrown ( see attached file ).<br />
<br />
The code I am using to create the group looks like this:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
TOC toc = new TOC();
toc.setExpression("row[\"column0\"]");
// Table Group
TableGroupHandle group0 = designFactory.newTableGroup( );
group0.setName("level0");
group0.setKeyExpr( "dataSetRow[\"column0\"]" );//$NON-NLS-1$
group0.addTOC(toc);
table.getGroups( ).add( group0 );</pre>
If I change the row <br />
<p class='bbc_indent' style='margin-left: 40px;'>toc.setExpression("row[\"column0\"]");</p>
to<br />
<p class='bbc_indent' style='margin-left: 40px;'>toc.setExpression("\"test\"");</p>
it works.<br />
<br />
Any help would be greatly appreciated.<br />
<br />
Regards Peter
Find more posts tagged with
Comments
mwilliams
Hi Peter,
Where are you writing this code? It seems to be having a problem with where this is set the value you're setting it to is null or something like that. Like the data is not yet available and it's checking and throwing an error.
pandersson
Hi Michael,<br />
<br />
thanks for your reply. I think I have found the problem but I do not know how to fix it. <br />
If I add a toc expression on a group in Eclipse I get the following xml:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<structure name="toc">
<expression name="expressionValue" type="javascript">row["column0"]</expression>
</structure>
</pre>
<br />
I try to create the above xml using the following code:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
TOC toc = new TOC();
toc.setExpression("javascript\">row[\"column0\"]");
((TableGroupHandle)table.getGroups().get(table.getGroups().getCount()-1)).addTOC(toc);
</pre>
but the result I get is:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<structure name="toc">
<expression name="expressionValue">javascript">row["column0"]</expression>
</structure>
</pre>
<br />
Is there perhaps a special method that can be used to get the wanted xml syntax?<br />
<br />
Regards Peter
pandersson
Hi,<br />
<br />
I finally got it to work. The following code generates the correct xml:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
TOC toc = new TOC();
Expression expression = new Expression("row[\"column0\"]", "javascript");
toc.setExpressionProperty("expressionValue", expression);
((TableGroupHandle)table.getGroups().get(table.getGroups().getCount()-1)).addTOC(toc);
</pre>
<br />
The intial problem that caused an Exception probably was that I had not started the ReportEngine correctly.<br />
<br />
Thanks for your time.<br />
<br />
Regards Peter
mwilliams
Peter,
Sorry for the delay in response. Glad you found the solution to your issue!