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)
Java code to create Report/Page variables in order to set dynamic footer
ravi11
<p>Hi,</p>
<p> </p>
<p>I am working on Page Variables in order to set a page footer. All I need is to write java code from birt api to set report variable and use its value in master page footer grid.</p>
<p> </p>
<p>VariableElementHandle var1 = new VariableElementHandle(module, element);</p>
<p> </p>
<p>I thought the above statement can be used for pageVaraible creation but I dont understand what module or element is to be given for a VariableElementHandle creation. I tried the following code but it has not worked as well.</p>
<p> </p>
<p>VariableElementHandle var1 = new VariableElementHandle(reportDesignHandle.getModule(), reportDesignHandle.getElement()); // throwing null pointer exception.</p>
<p> </p>
<p>I am attaching the sample rpt design file used for this process. Please help me in writing java code for this. And let me know if there is any other easy way of doing this job.</p>
<p> </p>
<p>Thanks in advance.</p>
<p>Ravi</p>
Find more posts tagged with
Comments
ravi11
<p>Hi,</p>
<p> </p>
<p>I tried to create a Report Variable and add it to the variables of the report by using the below mentioned code,but nothing seems to work. Can any one tell me where I am going wrong.</p>
<p> </p>
<p> VariableElementHandle var1 = reportDesignHandle.getElementFactory().newVariableElement("variable1");<br>
var1.setVariableName("variable1");<br>
var1.setName("variable1");<br>
var1.setType(DesignChoiceConstants.VARIABLE_TYPE_REPORT);<br>
var1.setValue("no value");<br>
reportDesignHandle.getPageVariables().add(var1);</p>
<p> </p>
<p>Thanks,</p>
<p>Ravi.</p>
ravi11
<p>Hi,</p>
<p> </p>
<p>The below mentioned code is working for me to add a Page varaiable.</p>
<p> </p>
<p>Expression expression = null;<br>
reportDesignHandle.setPageVariable("var1", expression);</p>
<p>VariableElementHandle pageVariable = reportDesignHandle.getPageVariable("var1");<br>
pageVariable.setType(DesignChoiceConstants.VARIABLE_TYPE_PAGE);</p>
<p> </p>
<p>Ravi.</p>