没有合适的资源?快使用搜索试试~ 我知道了~
sap开发中的上传下载,希望对你的开发有所帮助
资源详情
资源评论
资源推荐
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 1
How to Upload and Download Files
in an Web Dynpro for Java
Application
Applies to:
Web Dynpro for Java 7.11
Summary
In this tutorial you learn how to download and upload files within Web Dynpro applications by utilizing the
dictionary type Resource and its related Web Dynpro APIs IWDResource and WDResourceFactory
which are available since SAP NetWeaver 04s. In contrast to the dynamic type modification of a binary
context attribute in SAP NetWeaver 04, the dictionary simple type Resource yields a fully declarative, zero
coding data transport of download and upload resources between Web Dynpro client and controller context
on server side.
Author: Web Dynpro Java Team
Company: SAP AG
Created on: 15 January 2010
How to Upload and Download Files in an Web Dynpro for Java Application
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 2
Table of Contents
Prerequisites ....................................................................................................................................................... 3
Objectives ........................................................................................................................................................... 3
Some Theory ...................................................................................................................................................... 4
Using the Virus Scan Interface ....................................................................................................................... 4
The Tutorial Application ...................................................................................................................................... 5
Imlementation Details ......................................................................................................................................... 7
Uploading Files ............................................................................................................................................... 7
Downloading Files ........................................................................................................................................... 9
Extended Upload and Download features .................................................................................................... 11
Uploading Files in a Table.......................................................................................................................................... 12
Downloading Files in a Table Using On-Demand Resources .................................................................................... 15
Further Information ........................................................................................................................................... 24
Legend 24
Text Symbols ................................................................................................................................................ 24
Copyright........................................................................................................................................................... 25
How to Upload and Download Files in an Web Dynpro for Java Application
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 3
Prerequisites
You need to install the NetWeaver Developer Studio (Version 7.11 or later) in order to compile and deploy
the tutorial application. The SAP Java AS to which this application is deployed should have the same or
newer version as the NWDS.
The tutorial application is available as a development component (DC). You need to import the software
component HM-WDUIDMKTCNT, which contains the DC tc/wd/tut/file/updwnld. The exact steps
are described in a separate document.
Objectives
By the end of this tutorial, you will be able to:
Use the UI element FileUpload.
Use the UI element FileDownload with different file download behaviors
Assign the dictionary simple type Resource to context attributes so that they can store MIME files.
Create objects of type IWDResource from an image resource deployed with the project by invoking
the WDResourceFactory API.
Implement On-Demand Resources for Downloads.
How to Upload and Download Files in an Web Dynpro for Java Application
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 4
Some Theory
The Web Dynpro UI Element Library provides two special UI elements (FileDownload and FileUpload) with
which you can download files from the Web Dynpro runtime environment or upload them there. This is
performed using declarative data binding. Here, Web Dynpro runtime automatically transports different types
of MIME files between the client-side user interface or UI element and the server-side controller context.
In contrast to the semi-declarative approach in SAP NetWeaver 04, which was based on invoking the
IWDModifiableBinaryType-API in the controller code, the new dictionary simple type Resource within
SAP NetWeaver 04s yields a fully-declarative data transport of MIME resources between Web Dynpro client
and controller context on server side. The old IWDModifiableBinaryType-API should not be used
anymore since SAP NetWeaver 04s. The reasons for this are described in the chapter Implementation
Details.
In SAP NetWeaver 04s file download and upload was significantly enhanced and simplified with the following
new features:
Dictionary Type Resource: The new Java dictionary type Resource allows to bind FileUpload and
FileDownload UI elements to context attribtues storing MIME files named resources. In SAP
NetWeaver 04 the primitive type binary must be used.
Java Type IWDResource: The new Web Dynpro interface IWDResource is the Java type
counterpart of the dictionary type Resource. It allows to store the file content (binary resource data)
and the file metadata (MIME type, resource name) in one object. Consequently the resource
metadata (MIME type, file name) must no longer be stored in the context attribute info
(IWDAttributeInfo) using a modifiable binary type and may therefore differ among multiple
resources or node elements stored in the same context node.
Web Dynpro Factory WDResourceFactory: Resource objects of type IWDResource can easily
be created with the new Web Dynpro factory class WDResourceFactory. This factory class
significantly simplifies the implementation of file download scenarios where statically deployed or
dynamically created resources must be stored in the context.
Zero Coding File Upload: With the new Java dictionary type Resource it is no longer needed to
implement the type modification of a binary context attribute by invoking the
IWDModifiableBinaryType API in the controller code. Consequently file upload can be realized
in a purely declarative, zero coding approach. You just have to bind a FileUpload UI element to a
context attribute of type Resource. The Web Dynpro Runtime then automatically transports the
uploaded file to the context attribute as an object of type IWDResource.
File Download Behaviors: The behavior of the FileDownload UI Element can now be defined with
the new Java dictionary type FileDownloadBehavior. Its enumeration specifys three different file
download behaviors: open resource in-place without opening a dialog window, save resource in local
file system (open dialog) and open resource depending on the MIME type of the downloaded file
(open dialog).
Downloading Files in Tables On-Demand: The new on-demand streaming technique allows to
download the resource content on-demand when the user actually requests it on client side.
Especially when using the FileDownload UI element as table cell editor this new technique yields a
heavily reduced context memory consumption on server side.
Using the Virus Scan Interface
To enhance your system’s virus protection when working with files or documents processed by your Web
Dynpro applications, you can add external virus scanners to your SAP system using the Virus Scan
Interface.
To connect the FileUpload service contained in the Web Dynpro runtime environment to a virus scanner, you
need to activate the predefined virus scan profile webdynpro_FileUpload. This profile must be
activated/deactivated by the SAP J2EE Engine administrator. When delivered, profile
webdynpro_FileUpload is switched off. The Virus Scan Interface cannot be used for the Web Dynpro
FileDownload service.
How to Upload and Download Files in an Web Dynpro for Java Application
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
© 2010 SAP AG 5
Note that the example application presented in this tutorial does not use the Virus Scan
Interface. More details can be found in the SAP NetWeaver Help (see the link “Delivered Virus Scan
Profiles”) in the chapter Further Information.
The Tutorial Application
The screenshots displayed below show the views in the tutorial application.
When the application is launched, the WelcomeView appears, where you can navigate to the different
scenarios File Upload, File Download and Table.
When you press the Link “File Upload” the FileUploadView becomes visible. You can upload a file from your
computer to the server-side controller context. Once a MIME object has been uploaded, the system displays
details of the uploaded file, such as file name, file ending and file size.
In the FileDownloadView (reachable via the link “File Download”), you can download an image file, which is
deployed in the example project, from the controller context and display it on the user interface.
The file download behavior can be defined by clicking one of three radio buttons. The following screenshot
shows that the file download behavior ALLOWSAVE opens a dialog window to save the downloaded resource
on the local file system. With the behavior OPENINPLACE the resource is instantly displayed in another
browser window.
剩余24页未读,继续阅读
飞人lsp
- 粉丝: 0
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 处理数据的界面,使用pyqt+pandas开发da-console-tool-master.zip
- pandas 使用笔记study-pandas-master.zip
- 基于matlab的薛定谔方程数值计算应用源码(下载即用).zip
- docker ps: 列出运行中的容器 提供一个完整的微服务架构轻量级支撑运行时系统.zip
- 基于CS5080+TP4056 芯片5V输入4.2V 8.4V输出锂电充电控制板硬件(原理图+PCB)文件.zip
- 常用docker的参考命令.zip
- 基于matlab实现的模糊聚类分析项目源码.zip
- docker build: 从 Dockerfile 构建一个镜像
- 基于springboot的医院门诊管理系统源码.zip
- 基于python的垃圾分类系统源码(高分优质项目).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0