cancel
Showing results for 
Search instead for 
Did you mean: 

FileDownload UI element

sid-desh
Advisor
Advisor
0 Kudos

Hi,

I want to place a link to a particular PDF file in the same manner in which links are present in the example matrix section of SDN. Following are my queries:-

1. Where in the directory structure should the file be present.

2. For using the file download UI element how should I set the DATA property of the UI element. How should I point the UI element to the PDF file.

Regards

Sidharth Deshpande

Accepted Solutions (0)

Answers (2)

Answers (2)

sid-desh
Advisor
Advisor
0 Kudos

Hi valery,

Thanks for the response. Regarding the first part again what will happen is that all the PDF files will be dumped in a particular location by an external tool and at runtime i need to search the directory and then if the file is present i need to provoide the link to that file.

Hence i need to know where should all the files be dumped so that i can have access to those files.

Do let me know incase you have not understood the query.

Regards

Sidharth

Former Member
0 Kudos

Sidharth,

I see no problem here: you can always read file content from any known location to array of bytes. Then everything will work as I described previously.

VS

Former Member
0 Kudos

Hi,

<i>1. Where in the directory structure should the file be present.</i>

It depends, since you have to populate in-memory context yourself. If you plan to deploy PDF files with your application -- then better place is <b>mimes</b> folder of your sources (or <b>mimes/<i><component-name></i></b>). Then you can get full path to file at run-time via

WDURLGenerator.getResourcePath(...)

<i>2. For using the file download UI element how should I set the DATA property of the UI element.</i>

Data property should be bound to WD Context attribute of type <b>binary</b>, java type used underneath is byte[].

Next you have to apply run-time modification to data type of binary attribute:

public void wdDoInit()
{
  /* @@begin wdDoInit() */
  /* The FileDownload UI element requires: */
  final IWDAttributeInfo fileAttrInfo = wdContext
    .nodeRoot()
      .getNodeInfo()
        .getAttribute("MyPdfFileContent");    


  final IWDModifiableBinaryType pdfType =
    (IWDModifiableBinaryType)
      fileAttrInfo
       .getModifiableSimpleType();

  /* In addition the FileDownload 
   * UI element needs for  defined resource types 
   */  
  pdfType.setFileName( "MyPdfFile.pdf" );
  pdfType.setMimeType( WDWebResourceType.PDF );
  /* @@end */
}

<i>How should I point the UI element to the PDF file.</i>

You have to read content of file as byte array (byte[]) and assign this "value" to attribute mentioned.

More info can be found in NetWeaver help:

SAP Web AS for Java Applications -> Reference Manual -> Standard Library of the UI Elements -> Web Dynpro FileDownload API – IWDFileDownload

Valery