cancel
Showing results for 
Search instead for 
Did you mean: 

ON DEMAND FILE DOWNLOAD - PDF file from the table

Former Member
0 Kudos

Hi all,

          • ON DEMAND FILE DOWNLOAD *******

We have a download link on each row in a table, when we clik on the download link its not opeing the file corresponding to the row, but its opening the first row file for all rows.

We are storing the PDF file in server "D://123.pdf", "D://124.pdf" etc...

Its not problem with server path becuase its opening the first file.

Node Name : Resource

Attributes : filePointer( IWDInputStream), fileName( String), fileResource ( Resource )

We are using proper data types for all, I hope no mistakes in our declarations/code.

This is the code init Method ( for testing we have hard coded )

-


String calcAttrName = IPrivateTestView.IResourceElement.FILE_POINTER;

IPrivateTestView.IResourceElement resourceElement;

// -


1. Resource Node Element -


resourceElement = wdContext.nodeResource().createResourceElement();

node.addElement(resourceElement);

resourceElement.setFileName("123.PDF");

resourceElement.setFileResource(

WDResourceFactory.createResource(

resourceElement.getAttributePointer(calcAttrName),

"123.PDF",

WDWebResourceType.PDF));

// / -


2. Resource Node Element -


resourceElement = wdContext.nodeResource().createResourceElement();

node.addElement(resourceElement);

resourceElement.setFileName("124.PDF");

resourceElement.setFileResource(

WDResourceFactory.createResource(

resourceElement.getAttributePointer(calcAttrName),

"124.PDF",

WDWebResourceType.PDF));

-


CODE in getter method:

public com.sap.tc.webdynpro.progmodel.api.IWDInputStream getResourceFilePointer(IPrivateTestView.IResourceElement element)

{

//@@begin getResourceFilePointer(IPrivateTestView.IResourceElement)

IWDInputStream onDemandStream = null;

FileInputStream fileInputStream = new FileInputStream(new File("d://"+element.getFileResource().getResourceName()));

msgMan.reportWarning(element.getFileName());

onDemandStream = WDResourceFactory.createInputStream(fileInputStream);

return onDemandStream;

//@@end

}

-


If we store the files in mimes/... folder location its working fine, but when we store the PDF files in server ( D://... ), its not working .

Our requirement is to store files in Server, not in Project structure.

Could you suggest ?

Thanks,

Akshaya

Accepted Solutions (0)

Answers (1)

Answers (1)

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Akshaya,

have you already read my article on <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b0e10426-77ca-2910-7eb5-d7d8982cb83f">Uploading and Downloading Files in Web Dynpro Tables"</a> yet? The descirbed solution is based on NW04s. In NW04 you cannot apply an on-demand download technique. You must prepopulate the all node elements with resource data/binary data in context attributes. The only possible enhancement regarding memory consumption is defining non-singleton child nodes with an attribute of type binary (cardinality 1..1). Based on validate-by-rendering only the visible non-singleton child nodes get validated by the Web Dynpro runtime.

Regards, Bertram