java - User defined variables are executed twice in jasper -


i tried use variable in jasper report. created list component below.

<componentelement>                 <reportelement x="0" y="0" width="426" height="50" uuid="a99e79ba-74a6-4224-a1e5-d8b8d557a42f"/>                 <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemalocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">                     <datasetrun subdataset="dataset2" uuid="61554b87-1110-4c24-848a-c74c83ca33aa">                         <datasourceexpression><![cdata[new net.sf.jasperreports.engine.data.jrbeancollectiondatasource(arrays.aslist("buenos aires", "córdoba", "la plata"))]]></datasourceexpression>                     </datasetrun>                     <jr:listcontents height="50" width="426"/>                 </jr:list> </componentelement> 

for list data source, added 3 elements ("buenos aires", "córdoba", "la plata"). create variable inside data set

<subdataset name="dataset2" uuid="c2f92ca6-ab45-4b91-89f6-2ca7a4c80d4e">         <variable name="variable1" class="java.lang.string">             <variableexpression><![cdata["variable value";system.out.println("variable")]]></variableexpression>             <initialvalueexpression><![cdata["initial value";system.out.println("initial")]]></initialvalueexpression>         </variable> </subdataset> 

when print out in console, output

initial  variable  variable  variable  variable  variable  variable 

seems variable executed every iteration of list. wonder why variable executed twice each iteration(3 x 2) , how prevent that? problem gives me big headache when tried put value list or want append stringbuilder.

any appreciated.


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -