tags:

views:

34

answers:

2

Hi guys, I am working on a web application that is used to print user receipts based on the supplied receipt number. I want to enhance it in such a way that when i supply receipt numbers from 1 to 100 it will print all 100 receipts. Is there any ways in Java to implement this. How can i implement this in Java ?

A: 

Use a Map with the receipt number as the key and the receipt's as values.

Map<String, Receipt> receipts = new HashMap<String,Receipt>();
//Put objects in the map
receipts.put(receipt_number,receiptObject);

//Later print them out
for(Receipt r : receipts.values()) {
   System.out.println(r);
}
Shervin
I used to take printout of the receipts. So how can i able to achieve this? Can it be done using the above code where i replaceSystem.out.println(r);code with my print document code.?
Vishal
I cannot help without knowing more about your code. You need to show some code first.
Shervin
A: 

Your print document code is probably generating some sort of PDF or other report format and sends it to a printer. I think you should collect all the receipts in one multi-page report and print that. If you provide more details about the reporting tool used we might be of more help.

Adriaan Koster
ya thats true. I am using jasper reporting tool in my application.So on the basis of search date criteria i used to display result which display receipt number and on clicking on that number it opens a pdf and then print it.
Vishal
So what I think you need to do is adapt your Jasper report so it can represent multiple receipts. Something along the lines of passing it a List<Receipt> instead of just a single Receipt, and edit the report to iterate over the list.
Adriaan Koster