[#3111] - Allow setting default filename and location in JRViewer

Category:
Enhancement request
Priority:
Normal
Status:
Acknowledged
Project: Severity:
Minor
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

While viewing a JasperPrint document with it's document name set eg:

JasperPrint doc;
...
doc.setName("SpecialReport - 2013-08-13");

boolean exitOnClose = false;
JasperViewer view = JasperViewer(doc,exitOnClose);

When you click save button in the viewer, the file chooser dialog's default filename is empty.
I would suggest to default the filename to the JasperPrint's name.

In the latest 5.2.0 source in JRViewer starting line 1165 it will use the previous folder saved into:

if (lastFolder != null)
{
fileChooser.setCurrentDirectory(lastFolder);
}

should be followed by:

//Set the filename and location to save in
if (jasperPrint != null && jasperPrint.getName() != null)
{
fileChooser.setSelectedFile(new File(defaultFileName));
}

or possibly to allow further customization, it would be great to pass through a default filename to the JRViewer utilize it:

JRViewer view = new JRViewer(doc);
view.setDefaultFilename("SpecialReport - 2013-08-13"); //new method
..

If this was the case then if the defaultFilename was set then the fileChooser could use that, if not then it could utilize
the JasperPrint name.

This would help make it easier to save using standardized filenames, but still allow the user to view and then save the report using
that standarized name while still allowing them to change the default and select the filetype.

A further enhancement would be to allow setting the "lastFolder" protected file by way of adding a "setDefaultFileSaveLocation(File)" method to
JRViewer to initialize a desired initial save folder. (eg for defaulting invoices to be saved in an invoices in one folder, receipts in another folder)

Thanks!

v5.2
jmaher's picture
347
Joined: Apr 18 2007 - 3:38am
Last seen: 1 year 6 months ago

1 Comment:

#1
  • Status:New» Acknowledged
  • Assigned:nobody» teodord
Feedback
randomness