Read iReport Excercises text version

iReport ­ An Introduction

Exercises

Exercise 1: ID Add borders to a field

In this exercise you will make some basic field property changes to a report format in iReport.

Concept: Field Properties Steps

1. Make a copy of the Birthday List report and re-name the report ID with your initials (for example, X2D-STD-010). 2. Download the format to your computer and open it with iReport. 3. Change the zoom level to Width. 4. Select and delete all the hard-coded field borders (shift-click to select multiple fields). 5. Select both the localID and ID column header fields and click `Same width (max)' tool. 6. Keeping the 2 fields selected, click the `Align to left margin' tool. 7. Repeat step 5 on each pair of detail fields and its associated column heading. 8. Select all the column header fields and click the `Horizontal space: Remove' tool. 9. Keeping the column headers selected, click the `Align to bottom band' tool. 10. Select all the detail fields, remove the horizontal space and align to top band. All fields should now be touching. 11. Right-click on any detail field, select Properties and you'll see that the field height is 12. Right-click anywhere in the detail band, select Band Properties and change the detail band height from 16 to 12. 12. Right-click on the ID column header field, select Properties, select the Border sub-tab. Set a 1-point border on the top, left, and bottom of the field. Set the left and right padding to 2. 13. Repeat for the localID field, setting the border on only the left and bottom. 14. Repeat for all fields, setting borders as needed. Where fields meet, set only one border between the 2 fields. Remember to set padding to 2 on all fields. 15. Save the report in iReport 16. In Aspen, upload, compile, save, and run the report.

Exercise 2: New String Field ­ Student PM Bus Number

In this exercise you will go through adding a new field to the report that is of the type String.

Concept: Java Field Names

To add a new field onto the report, you often need to reference the data dictionary.

Steps

1. Make a copy of the Student List report and re-name the report ID with your initials (for example, X2D-STD-004). Download and open in iReport. 2. In the Aspen District View, Admin top-tab, Data Dictionary side-tab. Select the Student table, then the Fields side-tab. 3. Find the PM Bus # field and make note of its JavaName: fieldB043 4. Return to iReport. Select Fields from the View menu or click on the calculator-looking tool. Click New. 5. Enter fieldB043 for the field name. Class type = java.lang.string 6. Click OK and close the Fields window. 7. The easiest method for adding a field is to select an existing field, such as $F{yog}, copy and paste it. This will save you the task of having to format the field. 8. Move the field into the desired location. Right-click the field, select Edit Expression and change yog to fieldB043. 9. Add a column heading field. 10. Save the report in iReport. 11. In Aspen, upload, compile, save, and run the report.

Exercise 3: New related field ­ Person Phone 01

In this exercise you will learn how to use the data dictionary to find the relationships between the report base table and related tables, and pull fields from a related table into a report.

Concept: Related tables Steps

1. Continue working with the Student List report. 2. In the Aspen District View, Admin top-tab, Data Dictionary side-tab. Select the Student table, then the Relationships side-tab. 3. The key to identifying related tables that can be accessed is that the related table has a value of 1 in the RRelType field, meaning that a single record relates to the primary report record. For example, there is 1 school to many students. You'll notice that the value of PRelType in the School relationship is N. Students : School Many N : : 1 1

4. The Person table is a special table. 1 Person record exists for every individual in the system, whether the individual be a staff member, parent, student, etc. Make note of the class name of the Person table: com.x2dev.sis.model.beans.Person 5. Select the Person table, find the HomePhone field and make note of its JavaName: phone01. 6. Return to iReport. Before you can reference a related table on a report, you must define it. 7. Select Fields from the View menu or click on the calculator-looking tool. Click New. 8. Enter person for the field name. Class type = com.x2dev.sis.model.beans.Person 9. Create a new field by copying an existing field, as you did in exercise 2. 10. Edit the expression of the new field and change to $F{person}.getPhone01() 11. Save the report in iReport. 12. In Aspen, upload, compile, save, and run the report.

Exercise 4: String Format Methods ­ First and Last Initials

In this exercise you will learn how to use java methods to format data.

Concept: Java Methods Steps

1. Continue working with the Student List report. 2. On the Document Properties, change the layout of the report to "Landscape". 3. We will be using fields firstName and lastName. These are the java names, and both fields reside on the person table. 4. We have already defined the person table on this report. 5. Create a new field by copying an existing field, as you have done in previous exercises. 6. Edit the expression of the new field and change the expression to $F{person}.getFirstName().substring(0,1) + $F{person}.getLastName().substring(0,1) 7. Save the report in iReport. 9. In Aspen, upload, compile, save, and run the report. 9. Reference any online java documentation for a list of available string methods and syntax. Refer to Class: String.

Exercise 5: Using functions ­ Primary Contact Name

In this exercise you will learn how to use X2-developed functions to relate to a specific record on a related table that has multiple related records.

Concept: Related tables that have multiple related records. Steps

1. Continue working with the Student List report. 2. Although the Contacts table is related to the Student table, it is related as below. Student : Contacts 1 1 : : Many N

3. The primaryContact function selects the first contact record for you, 4. Select Fields from the View menu or click on the calculator-looking tool. Click New. 5. Enter primaryContact.contact.nameView for the field name. Class type = java.lang.string 6. Click OK and close the Fields window. 7. Add the new field and a column heading to the report format. 8. Save the report in iReport 9. Upload and compile the format in Aspen 10. In Aspen, upload, compile, save, and run the report.

Exercise 6: New String Field ­ Student Grade Level

In this exercise you will go through adding a new field to the report that is of the type String.

Concept: Rearranging

In order to enter a new field onto the report, rearranging the existing fields is likely necessary. Keeping items in line is essential for having a clean looking report.

Steps

1. Continue working with the Student List report. 2. Select Fields from the View menu 3. Click New 4. Enter gradeLevel for the field name a. Refer to the Data Dictionary in X2 if you need to look up the name of the field. When viewing the Student table fields, use the Java bean name for new fields 5. Click OK 6. Close the Fields window 7. Click and drag to select the Homeroom, Sex, and YOG static text, the Homeroom, Sex, and YOG text fields, and any surrounding lines 8. Using the arrow keys, move the fields to the right closer to the edge of the report a. If you go too far, the objects will turn red 9. Click and drag to select the LASID and Name static text, the LASID and Name text fields, and any surrounding lines 10. Using the arrow keys, move the fields closer to the left edge of the report. Suggest leaving the amount of space that the YOG field uses. 11. Using the Shift key, click on the YOG static text and text field objects as well as the boundary lines (either left or right depending how you performed steps 7 and 9) 12. Hit CtrlV to paste the copies 13. Use the arrow keys to move the copies into position between Name and YOG 14. Right click on the YOG static text and choose Properties 15. Go to the Static Text tab

16. Click into the text area and change YOG to Grade 17. Click the red X to close the window (the field autosaves your changes) 18. Right click on the YOG text field and choose Properites 19. Go to the Text Field tab 20. Click into the text area and change the yog to gradeLevel a. The end result should be $F{gradeLevel} and be colored green 21. Click the red X to close the window 22. Save the report in iReport 23. Upload and compile the report in Aspen 24. Run the report

Exercise 7: New Date field ­ Student DOB

In this exercise you will learn how to use formatting patterns to display a field

Concept: Formatting Patterns

Using patterns allows you to specify how to format a nonString field to suit the needs to your report. Use the Patterns.pdf document, for more examples of pattern usage.

Steps

1. Continue working with the Student List report. 2. Right click on the YOG static text object and choose Properties 3. Go to the Static Text tab 4. Click into the text area and change YOG to DOB 5. Click the red X to close the window 6. Right click on the YOG text field object and choose Properties 7. Go to the Text Field tab 8. Click into the text area and change the text to $F{person}.getDob() 9. Still in the Text Field tab, change the Text Field Expression Class to java.util.Date 10. Type into the Pattern field how you want the date printed ­ using MM for month, DD for day, and yy(yy) for year a. MM/dd/yyyy for 04/23/2008 b. yyyyMMdd for 20080423 c. M/d/yy for 4/23/08 d. MMddyy for 042308 11. Save the report in iReport 12. Upload and compile the format in Aspen 13. Save the report in Aspen and run it

Exercise 8: Using functions ­ School Administrator

In this exercise you will learn how to use functions to dynamically pull data from related tables and also combine Text and Fields together

Steps

1. Continue working with the Student List report 2. Right click on the "Fields" under "Document Structure" and add a new field 3. Add 3 fields: a. school.administrator1.person.nameTitleCode b. school.administrator1.person.firstName c. school.administrator1.person.lastName 4. Right click on the Text field "$P{district}.getName()" 5. Click on the Text Field tab 6. Change the Text Field to: $F{school.administrator1.person.nameTitleCode} + " " + $F{school.administrator1.person.firstName} + " " + $F{school.administrator1.person.lastName} + ", Principal" 7. Save the report in iReport 8. Upload and compile the format in Aspen 9. Save the report in Aspen and run it

Information

iReport Excercises

10 pages

Find more like this

Report File (DMCA)

Our content is added by our users. We aim to remove reported files within 1 working day. Please use this link to notify us:

Report this file as copyright or inappropriate

762209


You might also be interested in

BETA
Microsoft Word - NDCMedisoft11.doc
CitectSCADAReports.book