on 03-20-2007 1:27 AM
Hi,
I've got a maybe simple problem, but didn't find any solution.
I get an PDF File from my application and open it as an external window.
This works fine
The URL contains not the filename but "unknown.pdf...".
How can i change that?
Following the code where i read the file and open the external window.
File file = controller.getReportFile(...);
byte[] fileData = null;
try {
fis = new FileInputStream(file);
fileData = new byte[(int) file.length()];
fis.read(fileData);
fis.close();
catch(Exception e) {
}
IWDWindow = null;
try {
IWDWebResource webResource = WDWebResource.getWebResource(fileData, WDWebResourceType.PDF);
window = wdComponentAPI.getWindowManager().createExternalWindow(webResource.getURL(), "Report", false);
window.open();
catch(Exception e) {
}
The URL looks like this (short form..)
".../~wd_key29_......./unknown.pdf?sap.session....."
I appreciate any help
Hi Peil,
Try this befor reading the file
IWDAttributeInfo attInfo =
wdContext.currentContextElement().node().getNodeInfo().
getAttribute("PdfSource");
ISimpleTypeModifiable type = attInfo.getModifiableSimpleType();
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) type;
binaryType.setFileName("Test.pdf"); // Set file name
binaryType.setMimeType(WDWebResourceType.PDF); // set the mime type
the PdfSource here stores the binary data read.
Do reward points if it helps
Regards
sid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your reply.
I'll try to detail what i want to do.
The context of the view looks like this:
Reports.creationDate
Reports.filename
Reports.filesize
Reports.period
This context is build up in wdDoModifyView and each context element will be bind to a column of a table, which i create manually.
The table is now filled with these context. One column includes a download link (LinkToAction) which is binded to the action "onActionDownloadReport".
In this action i read the leadSelection, get the filename of the current context element and send it to my background application which returns me the file.
The rest is shown in the first posting.
I tried to create the context attribute PdfSource as binary and the code you given me.
But nothing happens. It's also "unknown.pdf"
Maybe i have to bind the PdfSource to LinkToAction?
Following the code where i create the download link in table.
IWDLinkToAction link = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, null);
link.setText("Download");
link.setOnAction(wdThis.wdGetDownloadReportAction());
column.setTableCellEditor(link);
table.addColumn(column);
Regards
Ingo
I solved it.
I displaced IWDWebResource with IWDCachedWebResource.
This interface provides the method setResourceName(String name).
String fileName = file.getAbsoluteFile().getName();
IWDCachedWebResource webResource = WDWebResource.getWebResource(fileData, WDWebResourceType.PDF);
webResource.setResourceName(fileName);
Now the filename appears in the URL.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.