cancel
Showing results for 
Search instead for 
Did you mean: 

FileDownload UI Element

J_B
Explorer
0 Kudos

Hy all,

i want to implement the Function of the FileDownload UIElement to a normal Button. If the Button was pressed the download of the file should be starts.

What is the best way to implement this scenario ?

First i have implemented the "normal" FileDownload with the UI Element and it works fine !

My question is, on which place(wdDoInit, wdDoModifyView) i must create ("dynamicly" ?) a FileDownload Element and how ?

Is there a Methode to combine a Button with a FileDownload UI Element ?

Thanks for help.

Regards

J. Berndt

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Jurgen

The File Download element can use an image instead of link to action a download.

You can make this image look like a Web Dynpro button or just a symbolic image (to bypass multilingual requirements if you have any)

;-B

Regards

Pran

Message was edited by: Pran Bhas

J_B
Explorer
0 Kudos

Hy Armin, Hy Pran,

thanks for help !

But this is no solution for me, because i want to combine two steps with a button.

1. To generate a temporary file on the server and

2. To download this file from the server.

I look or search for a solution to handle this two steps with a "normal" button.

The best way i think is to set the visible-property of the FileDownload UI to false and manipulate the link-event of the UI Element at the action of the Button.

Or is there any other way to build up my scenario ?

Thanks for help.

Regards

Jürgen

thomas_chadzelek
Participant
0 Kudos

Hello,

as far as I can see, there is no way in NW04 to trigger the download from with the event handler code. Thus I cannot see any other option than to use the FileDownload UI element and have the user click on it. You could disable it initially and have a button "Create file", which must be used to create the file and enable the download link.

Maybe the next release brings support for files created on demand, just when the user initiates the download.

Best regards,

Thomas

Former Member
0 Kudos

It exists, but result is quite ugly, also I'm not sure whether or not this is a behavior by design.

DISCLAIMER: Code below uses public API, but side-effects of call (very-very specific) are not documented for IWDModifiableBinaryType.

1. You can get type of binary attribute, something like

final ISimpleType type = 
  (
    (ISimpleType)wdContext.getNodeInfo().getAttribute("MyBinaryAttr").getDataType()
  ).cloneType();

2. Next you can get URL to binary content:


final byte[] data = "Hello, World!".getBytes("UTF-8");
final String url = type.format(data);

3. Now you can open a new window via component window manager using this url. The download will start, but user will see ugly empty explorer window

Some remarks. I'm not sure whether magic in [2] is for common use. Format method itself is public, but the fact it places binary content somewhere on server and return URL... Well, for me it is an overkill. Could someone from WD team provides comments on this?

Second, someone tries to use this URL for internal IFrame. And he was observing like download started with every WD action invocation. No resolution so far for this behavior.

Third, this URL could not be used in exit plug -- binary content created seems to be destroyed on exiting component. WD-authors, is it really so? And when all that temporary content is cleared if otherwise?

Regards,

VS

Former Member
0 Kudos

Hello Jürgen,

we faced the same problem. I wanna share my experience: We had a table of FileDownload Elements and it would not be feasible to load all of them just because a user might click them. This is way to slow and memory consuming.

First solution was to have two controls, a "download" button and a FileDownload control which becomes active only after downloading the file.

People were not understanding this, no usability at all.

Our current approach to workaround this issue is to have a link which just opens up a webdynpro popup window which than loads the specific file and provides it via a download link (and possibly some more information on the file). Not the best solution also but it leads the user better... this works pretty good now

Regards

Bruno

Former Member
0 Kudos

Hello.

Use the IWDFileDownload UI element itself for this task. If you want to change its visual design, you could change the stylesheet/theme. There are articles on how to do this in the SDN Developer Area section for Web Dynpro.

To create a IWDFileDownload or any other UI element programmatically, you have to write code in method wdDoModifyView():


IWDFileDownload fd = (IWDFileDownload) view.createElement(IWDFileDownload.class, <id>);
/* bind it's properties to context attributes... */
fd.bindXYZ(<context path>);
/* add it to some container... */
container.addChild(fd);

Armin