Support > Repository > Form > PDF output using JasperReports (2) List display
ja | en

Explain handling of list display using JasperReports.

This document is "PDF output using JasperReports (1) Detailed displayOn the premise of the knowledge of "List display data handling different points will be explained.

How to use JasperReports and how to design a form is not subject to Wagby support.Please consult Wagby dealer who has JasperReports engineer.At some agencies, training courses such as training are being held.

Sample data in XML format

  1. Launch the built Wagby application.
  2. Wagbyapp \ webapps \ wagby \ $ (model name) \ showList $ (model name) Opens _body.jsp with a text editor.Notepad attached to Windows can not be used.Please use a text editor such as TeraPad.
  3. Add two lines <c: out value = "$ {(model name) _lp}" /> and <c: out value = "$ {model name) _ cp}" />.The former is list display data and the latter is search condition data.Here is an example of the customer model.
    <%@ page pageEncoding="UTF-8" %>
    <fmt:setBundle basename="jfcapp"/>
    <c:out value="${customer_lp}"/>
    <c:out value="${customer_cp}"/>
    
  4. Log on to the application and open the list screen of this model.Data in XML format is displayed at the top of the screen.This is the test data used for form layout design in Jaspersoft Studio.
  5. Use the mouse to select and copy the displayed XML data.Save the data as a text file.(The file name is a combination of half-size alphanumeric characters and the extension is ".xml".) The character code is utf-8.
  6. In addition, add the following two lines to the beginning of this text file.
    <?xml version="1.0" encoding="utf-8"?>
    <root>
  7. Add the following line to the last line.
    </root>

In the following description, it is assumed that the test data for the list form is saved as "c: \ customer_showlist.xml".

<?xml version="1.0" encoding="utf-8"?>
<root>
  <customer_lp sortable="customerid " sort="" order=""><!-- 一覧表示用のデータ -->
    <item>
      <customerid>1000</customerid>
      <name>琉球太郎</name>
    </item>
    <item>
      <customerid>1001</customerid>
      <name>琉球次郎</name>
    </item>
  </customer_lp>
  <customer_cp><!-- 検索条件として入力した値 -->
    <customerid1jshparam errorcode=""></customerid1jshparam>
    <customerid2jshparam errorcode=""></customerid2jshparam>
    <name errorcode=""></name>
  </customer_cp>
</root>

In the list display, an item element is prepared for each data.There are ten item elements if there are ten display data.

Explain the differences from the detailed display setting.

Data Adapter Wizard

Prepare the data source "XML document".In the example we will name the name "showListCustomer" and associate it with customer_showlist.xml.

The difference from the detailed display setting is to write/root/customer_lp/item in the Select Expression field.

Figure 1 Data Adapter Wizard Setting Screen

Dataset and Query

Since we have specified Select Expression in Figure 1, we only need to specify the description of each field for the rest of the field.

Figure 2 Dataset and Query Dialog

Source

All settings can be confirmed on the Source tab.Here is an example of setting the list form.

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version last-->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="showListCustomer1" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b7ae9a9e-9321-4dc5-9b76-e4fa9877d839">
  <property name="com.jaspersoft.studio.data.defaultdataadapter" value="showListCustomer"/>
  <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
  <queryString language="xPath">
    <![CDATA[/root/customer_lp/item]]>
  </queryString>
  <field name="Field_1" class="java.lang.String">
    <fieldDescription><![CDATA[name]]></fieldDescription>
  </field>
  <background>
    <band splitType="Stretch"/>
  </background>
  <title>
    <band height="79" splitType="Stretch"/>
  </title>
  <pageHeader>
    <band height="35" splitType="Stretch"/>
  </pageHeader>
  <columnHeader>
    <band height="61" splitType="Stretch"/>
  </columnHeader>
  <detail>
    <band height="125" splitType="Stretch">
      <textField>
        <reportElement x="180" y="30" width="100" height="20" uuid="84eea6ac-1884-4e4c-87b5-45f1064327d9"/>
        <textElement>
          <font pdfFontName="HeiseiKakuGo-W5" pdfEncoding="UniJIS-UCS2-H"/>
        </textElement>
        <textFieldExpression><![CDATA[$F{Field_1}]]></textFieldExpression>
      </textField>
    </band>
  </detail>
  <columnFooter>
    <band height="45" splitType="Stretch"/>
  </columnFooter>
  <pageFooter>
    <band height="54" splitType="Stretch"/>
  </pageFooter>
  <summary>
    <band height="42" splitType="Stretch"/>
  </summary>
</jasperReport>

Since the reference XPath (/ root/customer_lp/item) has already been specified in the list form, "Description" is only the item name.

Item type Inscription Description Specification example
String, number, date item name The value of the item is posted. customer_name
Model reference (except check box) Item name/@ content The content part is posted. companyname/@content
Item name/@ id The ID part of the model is posted. companyname/@id
Model reference (check box) Item name [subscript]/@ content The content part of the model corresponding to the subscript is posted.Subscript starts from "1". customertype[2]/@content
Item name [subscript]/@ id The ID part of the model corresponding to the subscript is posted.Subscript starts from "1". customertype[2]/@id
Repeat item Item name [subscript] The value of the repetition item corresponding to the subscript is posted.Subscript starts from "1". email[2]/@content
Items in the repeating container Item name of container [subscript]/item name The value of the item in the repeating container corresponding to the subscript is posted.Subscript starts from "1". report[2]/rdate

JasperReports has a database connection function by JDBC.By using SQL, you can also operate the table generated by Wagby directly to collect data and output the report.

We do not set up JDBC in Japsersoft Studio.You can specify SQL for the queryString element of the configuration file jrxml as follows.

<parameter name="juser_cp.userid" isForPrompting="true" class="java.lang.String">
  <defaultValueExpression ><![CDATA["admin"]]></defaultValueExpression>
</parameter>

<queryString><![CDATA[select * from "juser" where "userid" = $P{juser_cp.userid}]]></queryString>

Enclose the table name and item name in double quotes.Parameters can also be specified with the notation $ P {...}. "Model name _ cp" refers to the model that stores the search condition.

"Form> PDF output using JasperReports (1) Detail display> Version of library to usePlease read.

An empty form is output

There is an error in the description of queryString in the configuration file jrxml.Please check whether it is a misspelling or a correct model name.

Example: The following setting is a list form targeting the customer model, but the following notation of root is incorrect.

<queryString language="xPath">
    <![CDATA[/root/customer/item]]>
</queryString>

It is correct as follows.

<queryString language="xPath">
    <![CDATA[/root/customer_lp/item]]>
</queryString>