A Parameter is a variable whose value is an input value at run time. You will always need to specify a parameter when running a report. For example, each time the report is run, the editor for the report would like to have his/her name placed in the report header section. You simply insert a parameter directly in the report, and each time you run the report, insert the value for the editor's name.
Or you may want to input order date as an input parameter when running a report so that only orders on that date will be displayed. That is, parameters can be used as part of the query condition (search criteria) so that only records satisfying that parameter value are retrieved. In addition, JReport parameters can also be used for Dynamic group or sort.
Reference Note: User's Guide | JReport Parameter and its Applications.
Data Information Properties:
- Type: Type for the parameter value, we support Integer, Number, String, Currency, Boolean, Date, Time, DateTime.
- Value: Default value for the parameter.
- UserFormat: User define format for the parameter value at report run time. For example, you define a parameter of Date type. We recognize the following formats: M/d/yy; MMM d, yyyy; MMMM d, yyyy; EEEE, MMMM d, yyyy. But if you want to enter a value like 1996.July.10, so you should specify the user defined format as yyyy.MMMM.d. But remember it is the entering format, not the display format. To customize the display format, go to its Format property in Report Inspector, enter your customized display format as yyyy.MMMM.d. Then when you enter 1996.July.10, it will be displayed as 1996.July.10.
Reference Note: The letters standing for year, month etc. are case sensitive and should follow the standard of JDK java.text.DateFormat, java.text.NumberFormat etc.- Limit: For the default value you will specify for your parameter, we also give the choice of specifying the minimum and maximum value. This will list the range for the two values.
Other Properties:
- Name: Parameter name. It is identity of the parameter, since when you hope to assign a different value for the parameter, you will use it as an identity.
- PromptText: Prompting text for your information. You may leave this to be empty while defining the parameter.
How does one define user format for different types of parameters? The most commonly used are Date, Time format as introduced above.
Date Format Syntax
To specify the time format, use a time pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as follows:
Symbol Meaning Presentation Example G era designator Text AD y year Number 1996 M month in year Text & Number July & 07 d day in month Number 10 h hour in am/pm (1~12) Number 12 H hour in day (0~23) Number 0 m minute in hour Number 30 s second in minute Number 55 S millisecond Number 978 E day in week Text Tuesday D day in year Number 189 F day of week in month Number 2 (2nd Wed in July) w week in year Number 27 W week in month Number 2 a am/pm marker Text PM k hour in day (1~24) Number 24 K hour in am/pm (0~11) Number 0 z time zone Text Pacific Standard Time ' escape for text '' single quote Notes:
- The count of pattern letters determine the format.
- Text: 4 or more pattern letters--use full form, < 4--use short or abbreviated form if one exists.
- Number: the minimum number of digits. Shorter numbers are zero-padded to this amount. Year is handled specially; that is, if the number of letter 'y' is 2, the year will be truncated to 2 digits.
- Text & Number: 3 or over, use text, otherwise use number.
- Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.
- A pattern containing any invalid pattern letter will result in a thrown exception during formatting or parsing.
Examples Using the US locale:
Format Pattern: "yyyy.MM.dd G 'at' hh:mm:ss z"
Result: 1996.07.10 AD at 15:08:56 PDTFormat Pattern: "EEE, MMM d, ''yy"
Result: Wed, July 10, '96Format Pattern: "h:mm a"
Result: 12:08 PMFormat Pattern: "hh 'o''clock' a, zzzz"
Result: 12 o'clock PM, Pacific Daylight TimeFormat Pattern: "K:mm a, z"
Result: 0:00 PM, PSTFormat Pattern: "yyyyy.MMMMM.dd GGG hh:mm aaa"
Result: 1996.July.10 AD 12:08 PMDecimal Number Format Syntax
Symbol Meaning Notes 0 a digit * a digit, zero shows as a star Can't mix 0, *, and _ in same format _ a digit, zero shows as a space Can't mix 0, *, and _ in same format # a digit, zero shows as absent . placeholder for decimal separator , placeholder for grouping delimiter Shows the interval to be used ; separates formats positive and negative. - if there is no explicit negative sign, - is prefixed "0.00" -> "0.00;-0.00" % divide by 100 and show as percentage X any other characters can be used in the prefix or suffix