Define report totals (Java)

In your Java report application, define variables for the totals, calculate the values, and output them to the report engine.

Code examples shown here can be found in OrderReportModel.java, part of the OrderReportJava demo application. Examine that file to see the code fragments in context of a complete application. This application accumulates the subtotals on a per-row basis.
  1. Open the Java file.
  2. Define the appropriate variables:
        private double overalltotal;
        private double usertotal;
        private double ordertotal;
  3. Reinitialize totals on appropriate iterator:
    usertotal = nextRow.lineitemprice;
    report.ordertotal = report.nextRow.lineitemprice;
  4. Calculate totals on each row of data:
        overalltotal += lineitemprice;
        usertotal += lineitemprice;
        ordertotal += lineitemprice;
        nextRow.lineitemprice = lineitemprice;
        nextRow.overalltotal = overalltotal;
        nextRow.usertotal = usertotal;
        nextRow.ordertotal = ordertotal;
  5. Specify variables in the Row class, with specific XML annotations (for relevant information in the data schema (.xsd), and use meaningful variable names:
        @XmlElement(name = "overalltotal", required = true, nillable = true)
        public Double overalltotal;
        @XmlElement(name = "usertotal", required = true, nillable = true)
        public Double usertotal;
        @XmlElement(name = "ordertotal", required = true, nillable = true)
        public Double ordertotal;