cancel
Showing results for 
Search instead for 
Did you mean: 

Generating file via web service and store it on client's hard disc

Former Member
0 Kudos

Hello!

First of all I want to see that i am a beginner concerning Web Dynpro.

In the last weeks I made a lot of steps but now i am stuck with a problem, i didn't find a helpful solution for.

I want to create a textfile dynamically via web serivce. That works fine.

Now I am looking for a solution to write this file on client hd.

Is there a possibility to use simply the Java "File" class and give the path name or do I have to use the wd download ui?

For the downloadUI I only found examples concerning Files in MIME but i don't know what to do if my file is dynamically created during runtime and not stored on any hard disc.

I would be grateful if you could get me some hints to find the right way.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

FileDownload UI is what you should be using!

Bind the 'resource' property of the FileDownload UI element to a context attribute (say with name SomeFile) of type

com.sap.ide.webdynpro.uielementdefinitions.Resource

in local dictionary. Insert the following piece of code where the file content is dynamically being generated.


Byte[] dynamicFileConent = yourFileContentGenerateMethod(); // your logic
IWDResource resource = 
         WDResourceFactory.createResource(dynamicFileConent ,"FILE_NAME.TXT",WDWebResourceType.UNKNOWN);
wdContext.currentContextElement().setSomeFile(resource); // SomeFile is the name of the Context Attribute

Regards

kk

Edited by: kaushal kishore on Mar 16, 2010 6:45 PM

Former Member
0 Kudos

Hey kk!

thank you for your answer and the code example.

This is what I was looking for!!! Nice.

I also have to bind the 'data' property of the downloadUI element.

In your example the value of 'dynamicFileConent' has to be bound that property element....am I right?

Former Member
0 Kudos

>

> Hey kk!

>

> thank you for your answer and the code example.

> This is what I was looking for!!! Nice.

>

> I also have to bind the 'data' property of the downloadUI element.

> In your example the value of 'dynamicFileConent' has to be bound that property element....am I right?

Hi

No need to bind the 'data' propery of the downloadUI element. Just bind the 'resource' property of the FileDownloadUI element to the context attribute as suggested in my previous reply.

Binding 'data' property was the older way of doing things.

Regards

kk

Former Member
0 Kudos

Tried it and it works properly.

Thanks for the fast and professional help!

Cheers

former_member182374
Active Contributor
0 Kudos

Hi,

The only way to do it is by using signed ActiveX (FSO) on IE explorer or signed applet.

This is due security reasons - a web server cannot access client machine...

In case you're in intranet environment and you're working with IE it's possible by changing some parameters in the IE configuration and using FSO.

Regards,

Omri

Former Member
0 Kudos

Hello Omri,

thanks for your quick answer.

It seems that i have to get some information about your proposal.

Do you think there is no solution with wd?

(like creating a temporary file on the server which is removed after the user has downloaded it?)

former_member182374
Active Contributor
0 Kudos

Hi,

This has nothing to do with Web Dynpro/SAP, it's related to browser and what a web server can do on a client.

In ASP/PHP you have the same restrictions.

By using ActiveX, applet you can bypass those security issues and write a file to the client's disk.

Regards,

Omri