!--a11y-->
Web
Dynpro FileDownload API – IWDFileDownload 
You can use the FileDownload UI element to load files from the server to the client. The data property determines the data source in the view context. The target property determines the ID of the target window in the browser. For more information about this UI element, see the Binding section below.
·
data
Determines the data source of
the files to be downloaded in the context.
·
target
Determines the ID of the target window in the browser, if the link is
activated. Either the users can specify the ID themselves or it has the value
_blank, which opens an external, unnamed
window.
·
type
Describes the graphical
representation of the FileDownload UI element. The type property can be filled with the following
values and is represented by the enumeration type WDLinkType.
function |
|
The UI element appears in the standard design and underlined. |
navigation |
|
The UI element appears underlined and in the color used for links that the user has already visited. |
reporting |
|
The UI element appears in the standard design and not underlined. |
result |
|
The UI element appears not underlined. |
Name |
Interface |
Type |
Initial Value |
bindable |
Value Required |
data |
IWDFileDownload |
Object |
|
bindable_mandatory |
No |
IWDUIElement |
boolean |
true |
bindable |
No |
|
IWDAbstractCaption |
String (TranslatableText) |
|
bindable |
No |
|
IWDAbstractCaption |
boolean |
true |
bindable |
No |
|
IWDLink |
String |
|
bindable |
No |
|
IWDAbstractCaption |
String |
|
bindable |
No |
|
IWDLink |
String |
|
bindable |
No |
|
IWDLink |
WDLinkSize |
standard |
bindable |
No |
|
target |
IWDFileDownload |
String |
_BLANK |
bindable |
No |
IWDLink |
String (TranslatableText) |
|
bindable |
No |
|
IWDUIElement |
String (TranslatableText) |
|
bindable |
No |
|
type |
IWDFileDownload |
WDLinkType |
navigation |
bindable |
No |
IWDUIElement |
WDVisibility |
visible |
bindable |
No |
|
IWDLink |
boolean |
false |
bindable |
No |
At design time, you add the FileDownload UI element to an appropriate view. You then define a value attribute of type binary in the context of this view, also at design time; for the source text below the value attribute is called “FileDownload”.
The data property must be bound to this value attribute of data type binary, so that the file can be downloaded as a byte array. At runtime, the binary data type can be enhanced with data to allow the passing of related information when downloading a file. Using the IWDModifiableBinaryType data type, which represents an extension of the binary data type you can access the MIME type of the file, that is, either read or set the MIME type. To do this, you must implement the following source text in the wdDoInit method of the controller implementation, with which, on the one hand, the binary data type is enhanced at runtime and on the other hand, the file extension is passed on during download:
public void wdDoInit() { //@@begin wdDoInit() // The FileDownload UI element requires: IWDAttributeInfo attInfo = wdContext.nodeRoot().getNodeInfo().getAttribute("FileDownLoad"); binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();
// in addition the FileDownload UI element needs for defined resource types binaryType.setFileName("Snow Trees.jpg"); binaryType.setMimeType(WDWebResourceType.JPG_IMAGE);
//The FileDownload UI element needs for undefined resource types binaryType.setFileName("Snow Trees.xcc"); binaryType.setMimeType(new WDWebResourceType("xcc", "", true));
//@@end } |

Note that during the download, the MIME type of the file must be set in the controller implementation. Furthermore, you must pass on additional parameters to the setMimeType method, if the data type is not available in the Java Dictionary.
Method Name |
Parameter |
Return Value |
Short Description |
bindData |
(String path) |
|
Binds the value of the data property to the content element specified by the path. |
bindingOfData |
|
String |
Returns the path of the content element to which the data property is bound. Returns NULL if no binding exists. |
bindingOfTarget |
|
String |
Returns the path of the context element to which the target property is bound. Returns NULL if no binding exists. |
bindingOfType |
|
String |
Returns the path of the context element to which the type property is bound. Returns NULL if no binding exists. |
bindTarget |
(String path) |
|
Binds the target property to the context node specified by a path. |
bindType |
(String path) |
|
Binds the type property to the context node specified by a path. |
getData |
|
Object |
Returns the value of the data property. |
getTarget |
|
String |
Returns the value of the target property. |
getType |
|
WDLinkType |
Returns the value of the type property. |
setData |
(Object data) |
|
Sets the value of the data property. |
setTarget |
(String target) |
|
Sets the value of the target property. |
setType |
(WDLinkType type) |
|
Sets the value of the type property. |
Additional methods described in the following APIs are available using inheritance:
IWDLink, IWDAbstractCaption, IWDUIElement, IWDViewElement.

For detailed documentation of all inherited methods, see the documentation for the relevant APIs.
