Jump to content
Changes to the Jaspersoft community edition download ×

Dividing Parameters and FIelds


Recommended Posts

By: mike w - mwans

Dividing Parameters and FIelds

2003-04-17 10:39

I am still fairly new to JAVA and Jasper. I have a report in which I am trying to compute a percentage. One value comes from a field and the other comes from a parameter. Both are class java.lang.Long. I want to divide them and display the result. But I get errors.

 

Here is my code:

 

<variableExpression>$F{COUNT}</variableExpression>

 

<initialValueExpression>$F{COUNT}==null?1:$F{COUNT}</initialValueExpression>

</variable>

<variable name="vPercent" class="java.lang.Long" resetType="None" calculation="Nothing">

<variableExpression>$F{COUNT}.toLong()/$P{TOTAL}.toLong()</variableExpression>

<initialValueExpression>$F{COUNT}.toLong()/$P{TOTAL}.toLong()</initialValueExpression>

</variable>

 

 

<group name="LocationGroup">

<groupExpression>$F{SHORT_DESCRIPTION}</groupExpression>

<groupHeader>

<band height="30">

<textField>

<reportElement positionType="Float" x="3" y="0" width="172" height="30"/>

<textElement textAlignment="Left">

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{SHORT_DESCRIPTION}]]></textFieldExpression>

</textField>

<textField>

<reportElement positionType="Float" x="183" y="0" width="42" height="30"/>

<textElement textAlignment="Left">

</textElement>

<textFieldExpression class="java.lang.Long"><![CDATA[$F{COUNT}==null?new java.lang.Long(0):$F{COUNT}]]></textFieldExpression>

 

</textField>

 

<textField>

<reportElement positionType="Float" x="225" y="0" width="42" height="30"/>

<textElement textAlignment="Left">

</textElement>

<textFieldExpression class="java.lang.Long">($F{COUNT}==null)?new java.lang.Long(0):($F{COUNT}.longValue()/$P{TOTAL}.longValue())></textFieldExpression>

</textField>

 

.

.

.

 

 

 

Here are some errors:

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:145: illegal start of expression

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:145: ')' expected

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:263: illegal start of expression

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getOldValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getOldValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:263: ')' expected

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getOldValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getOldValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:381: illegal start of expression

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:381: ')' expected

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:100: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:100: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:100: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:110: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:110: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:110: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:120: incompatible types

found : java.lang.Long

required: int

 

value = (java.lang.Long)(((java.lang.Long)parameter_TOTAL.getValue())==null?1:((java.lang.Long)parameter_TOTAL.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:120: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)parameter_TOTAL.getValue())==null?1:((java.lang.Long)parameter_TOTAL.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:145: incompatible types

found : boolean

required: java.lang.Long

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:195: incompatible types

found : java.lang.Long

required: int

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue())==null?1:((java.lang.Long)field_COUNT.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:195: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue())==null?1:((java.lang.Long)field_COUNT.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:218: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getOldValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:218: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getOldValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:218: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getOldValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:228: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getOldValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:228: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getOldValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:228: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getOldValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:238: incompatible types

found : java.lang.Long

required: int

 

value = (java.lang.Long)(((java.lang.Long)parameter_TOTAL.getValue())==null?1:((java.lang.Long)parameter_TOTAL.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:238: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)parameter_TOTAL.getValue())==null?1:((java.lang.Long)parameter_TOTAL.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:263: incompatible types

found : boolean

required: java.lang.Long

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getOldValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getOldValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:313: incompatible types

found : java.lang.Long

required: int

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getOldValue())==null?1:((java.lang.Long)field_COUNT.getOldValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:313: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getOldValue())==null?1:((java.lang.Long)field_COUNT.getOldValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:336: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:336: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:336: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:346: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:346: cannot resolve symbol

symbol : method toLong ()

location: class java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:346: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue()).toLong()/((java.lang.Long)parameter_TOTAL.getValue()).toLong());

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:356: incompatible types

found : java.lang.Long

required: int

 

value = (java.lang.Long)(((java.lang.Long)parameter_TOTAL.getValue())==null?1:((java.lang.Long)parameter_TOTAL.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:356: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)parameter_TOTAL.getValue())==null?1:((java.lang.Long)parameter_TOTAL.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:381: incompatible types

found : boolean

required: java.lang.Long

 

value = (java.lang.Long)((((java.lang.Long)field_COUNT.getValue())==null)?new java.lang.Long(0):(((java.lang.Long)field_COUNT.getValue()).longValue()/((java.lang.Long)parameter_TOTAL.getValue()).longValue())>);

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:431: incompatible types

found : java.lang.Long

required: int

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue())==null?1:((java.lang.Long)field_COUNT.getValue()));

 

^

 

C:ECPRPT_TESTTable02TBL_02_EVENT_GROUP_SUB.java:431: inconvertible types

found : int

required: java.lang.Long

 

value = (java.lang.Long)(((java.lang.Long)field_COUNT.getValue())==null?1:((java.lang.Long)field_COUNT.getValue()));

 

^

 

39 errors

 

 

 

at dori.jasper.engine.design.JRCompiler.compileReport(JRCompiler.java:150)

 

at dori.jasper.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:129)

 

at dori.jasper.engine.JasperCompileManager.compileReportToFile(JasperCompileManager.java:117)

 

at IReportCompiler.main(IReportCompiler.java:119)

 

 

 

Abnormal termination!

 

 

 

 

By: Teodor Danciu - teodord

RE: Dividing Parameters and FIelds

2003-04-17 11:14

 

Hi,

 

The result has to be an object, not a primitive type:

 

<variableExpression>

new Long(

$F{COUNT}.toLong() / $P{TOTAL}.toLong()

)

</variableExpression>

 

I hope this helps.

Teodor

 

 

 

 

 

By: mike w - mwans

RE: Dividing Parameters and FIelds

2003-04-17 12:33

It worked. Thank you very much.

 

Mike

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...