cancel
Showing results for 
Search instead for 
Did you mean: 

FileDownload

Former Member
0 Kudos

Hi,

in my WD App. I want to download a file to the client computer. Because the content of the file has to be generated at runtime (data is coming from a backend system) I can´t use the FileDonwload control. There is no event that can be fetched to generate the outputstream when a user clicked at this control. The binary context attribute has to be filled before the user clicks the control.

Therefore I realized the following solution.

1. I enclosed an iFrame in my view with width and height = 0.

2. In the onAction method of a "Download" button I set the source property of the iFrame to a servlet

3. The servlet is responsible for retrieving the content that has to be downloaded and puts it into its response. Which data it has to collect is determined by a request parameter.

4. In my wdDoModify method I set the source of the iFrame to "" if the onActionDownload method has not been called.

This szenario works fine. Each time a server roundtrip is triggered by the client the iFrame source property is either set to the servlet URL or to "".

But there is also a table control at my view and when I scroll through this table a server roundtrip also is initiated without calling my wdDoModify method.

That leads to the following result. If I donwloaded a file and then scroll inside the table the file download dialog appears. This is because the source property of the iFrame was not set to "".

Does anybody know if there is a method that is called

each

time the client invokes an action at the server?

Or is there another way to realize a dynamic download?

Thanks in advance

Helmut

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Helmut,

what's about putting the download control inside a modal window? Then you can evaluate the action of an button which generates the binary content and opens the modal window in which the actual download can be started.

Best regards,

Christian

htammen
Active Contributor
0 Kudos

Hi Christian,

thank you for the suggestion. This could be a possible solution for my problem but I has two drawbacks.

1. Between pressing the download button in my Web Dynpro and appearance of the modal dialog a long time can be passed by because the whole file has to read and put into the binary context attribute. The filesizes can be very huge (1 KB up to 100 MB).

2. The user has to do one unnecessary click. First the download button in my Web Dynpro, then an OK button in the modal dialog and at last the save button in the save dialog of the operating system.

Best regards

Helmut

Former Member
0 Kudos

Hi Helmut,

I would try the following:

Use a ProgressIndicator and a TimedTrigger in the modal Window, this should be useful as you don't know the load time. This helps also to justify the additional click for the user.

In the Controller instantiate a Class which creates a new Thread for loading the data and indicating the progress. This progress should than be mapped to the ProgressIndicator in the action of the ProgressIndicator.

If the progress gets 100 take the data from the LoaderThread and map it to the context. Also make the download control visible at this moment.

To get this work you have to know the maximum number of loaded objects in advance of cause.

Best regards,

Christian

htammen
Active Contributor
0 Kudos

Hi Christian,

this sounds not bad. I will try it.

Thank you for your good ideas.

Helmut