iReport Ultimate Guide - Nimsoft Library
iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library
iReport Ultimate GuideFigure 6-5Query dialogiReport does not need you to define a query in order to generate a report. In fact, iReport could obtain data records from a datasource that is not defined by a query execution. Regardless, here is where you define it. The language of the query can be oneof those items listed in the combo box on the top of the query dialog. UR supports the most common querylanguages:• SQL• HQL• EJBQL• Xpath• MDX (both the standard and XMLA-encapsulated versions)Let’s focus on SQL. If the selected data source is a JDBC connection, iReport will test the access connection to the data sourceas you define the query. This allows iReport to identify the fields using the query metadata in the result set. The design toollists the discovered fields in the bottom portion of the window. For each field, iReport determines the name and the Java typespecified for that field by the JDBC driver.A query that accesses one or more tables containing a large amount of data may require a long delay while iReport scans thedata source to discover field names. You may want to disable the Automatically Retrieve Fields option in order to quicklyfinish your query definition. When you have completed the query, click the Read Fields button in order to start the fieldsdiscovery scan.All fields used in a query must have a unique name. Use alias field names in the query for fields having the samename.In case of an error during the query execution (due to a syntax error or to an unavailable database connection), an errormessage will be displayed instead of the fields list.The field name scan may return a large number of field names if you are working with complex tables. I suggest that youreview the list of discovered names and remove any fields that you are not planning to use in your report, in order to reduceunnecessary complexity.When you click the OK button all the fields in the list will be included in the report design. You canalso remove them later in the outline view, but it’s a good idea at this point in the design process to remove any field namesthat you won’t be using.98
6.1.2 Accessing the SQL Query DesignerFields, Parameters, and VariablesiReport provides a simple visual query designer to help you create simple SQL queries without having to know a particularlanguage. You can access the tool by clicking the button labeled Query designer (a JDBC connection must be active, and theselected language of the query must be SQL).Figure 6-6SQLeonardo Query DesignerThis SQL query designer, which comes from the SQLeonardo open source project, provides a drag-and-drop way to createqueries (see Figure 6-6).To create a query you need to drag the required tables into the main panel. Check which fields you will need. The designerallows you to define table joins. To join two tables, drag the field of one table over the field of another. Edit the join type byright-clicking the red, square joint icon in the middle of the join line. To add a condition, right-click the Where node in thequery tree. To add a field to the Group By and Order By nodes, right-click a field under the SELECT node.6.1.3 Registration of the Fields of a JavaBeanOne of the most advanced features of UR is the ability to manage data sources that are not based on simple SQLqueries. One example of this is JavaBean collections. In a JavaBean collection, each item in the collection represents a record.UR assumes that all objects in the collection are instances of the same Java class. In this case the “fields” are theobject attributes (or even attributes of attributes).By selecting the JavaBean Datasource tab in the query designer, you can register the fields which correspond to the specifiedJava classes. The concept here is that you will know which Java classes correspond to the objects that you will be using in yourreport.99
- Page 47 and 48: Report StructureGroup HeaderDetailG
- Page 49 and 50: Report StructureThe page margin dim
- Page 51 and 52: Report StructureFigure 4-6Result of
- Page 53 and 54: Report StructureMultiple columns ar
- Page 55 and 56: Report StructureFigure 4-11Properti
- Page 57 and 58: Report StructureAs you can see in F
- Page 59 and 60: Report Structure4.1.3.12 ImportsThe
- Page 61 and 62: Report Structureexample, in a repor
- Page 63 and 64: Report ElementsCHAPTER 5REPORT ELEM
- Page 65 and 66: Report ElementsFigure 5-3Guidelines
- Page 67 and 68: Report ElementsFigure 5-6Element no
- Page 69 and 70: Report ElementsTable 5-1Formatting
- Page 71 and 72: Report ElementsFigure 5-10Table 5-2
- Page 73 and 74: Report ElementsFigure 5-11Custom el
- Page 75 and 76: Report Elements5.1.5.2 RectangleThe
- Page 77 and 78: Report ElementsTable 5-4TypeImage E
- Page 79 and 80: Report ElementsTable 5-5OptionImage
- Page 81 and 82: Report ElementsCode Example 5-1Dyna
- Page 83 and 84: Report ElementsCode Example 5-2Prin
- Page 85 and 86: Report ElementsPDF font namePDF enc
- Page 87 and 88: Report ElementsFor your convenience
- Page 89 and 90: Report ElementsHere there are some
- Page 91 and 92: Report ElementsThe following briefl
- Page 93 and 94: 5.5 Adding Custom Components and Ge
- Page 95 and 96: Fields, Parameters, and VariablesCH
- Page 97: Fields, Parameters, and VariablesIn
- Page 101 and 102: Fields, Parameters, and Variables6.
- Page 103 and 104: 6.2.3 Built-in ParametersFields, Pa
- Page 105 and 106: Fields, Parameters, and VariablesRe
- Page 107 and 108: Fields, Parameters, and Variables6.
- Page 109 and 110: Fields, Parameters, and VariablesTa
- Page 111 and 112: Bands and GroupsCHAPTER 7BANDS AND
- Page 113 and 114: Bands and Groupsexpression may be r
- Page 115 and 116: Bands and GroupsFigure 7-6Dragging
- Page 117 and 118: Bands and GroupsFigure 7-10The firs
- Page 119 and 120: Bands and GroupsFigure 7-14 shows t
- Page 121 and 122: 7.3 Other Group OptionsBands and Gr
- Page 123 and 124: Fonts and StylesCHAPTER 8FONTS AND
- Page 125 and 126: Fonts and StylesThe list of availab
- Page 127 and 128: Fonts and StylesFigure 8-5Font Exte
- Page 129 and 130: Fonts and StylesFigure 8-7Font Exte
- Page 131 and 132: Fonts and StylesFigure 8-10The new
- Page 133 and 134: Fonts and StylesTo apply a style to
- Page 135 and 136: Fonts and StylesFigure 8-17The outl
- Page 137 and 138: TemplatesCHAPTER 9TEMPLATESOne of t
- Page 139 and 140: TemplatesFigure 9-2Columnar reportA
- Page 141 and 142: TemplatesFigure 9-4Group by step in
- Page 143 and 144: TemplatesIf a static text element i
- Page 145 and 146: TemplatesFigure 9-8Your custom temp
- Page 147 and 148: TemplatesFigure 9-10New template in
6.1.2 Accessing the SQL Query DesignerFields, Parameters, and Variables<strong>iReport</strong> provides a simple visual query designer to help you create simple SQL queries without having to know a particularlanguage. You can access the tool by clicking the button labeled Query designer (a JDBC connection must be active, and theselected language of the query must be SQL).Figure 6-6SQLeonardo Query DesignerThis SQL query designer, which comes from the SQLeonardo open source project, provides a drag-and-drop way to createqueries (see Figure 6-6).To create a query you need to drag the required tables into the main panel. Check which fields you will need. The designerallows you to define table joins. To join two tables, drag the field of one table over the field of another. Edit the join type byright-clicking the red, square joint icon in the middle of the join line. To add a condition, right-click the Where node in thequery tree. To add a field to the Group By and Order By nodes, right-click a field under the SELECT node.6.1.3 Registration of the Fields of a JavaBeanOne of the most advanced features of UR is the ability to manage data sources that are not based on simple SQLqueries. One example of this is JavaBean collections. In a JavaBean collection, each item in the collection represents a record.UR assumes that all objects in the collection are instances of the same Java class. In this case the “fields” are theobject attributes (or even attributes of attributes).By selecting the JavaBean Datasource tab in the query designer, you can register the fields which correspond to the specifiedJava classes. The concept here is that you will know which Java classes correspond to the objects that you will be using in yourreport.99