我使用 gwtupload ( http://code.google.com/p/gwtupload/ ),我需要添加启动文件。有人知道我该怎么做吗?
问问题
199 次
2 回答
1
我可以推断您想将以前上传的文件添加到多上传器列表中。MultiUploader
虽然你可以在项目网站上开一张票,但目前没有办法,我将在下一个版本中实现它。
但是您可以扩展MultiUploader
并编写解决方法,此示例有效:
public class GwtTestApp implements EntryPoint {
public void onModuleLoad() {
MyMultiUploader uploader = new MyMultiUploader("file1.txt", "file2.doc");
RootPanel.get().add(uploader);
}
public static class MyMultiUploader extends MultiUploader {
private VerticalPanel panel;
private Widget multiuploader;
@Override
protected void initWidget(Widget widget) {
panel = new VerticalPanel();
super.initWidget(panel);
multiuploader = widget;
}
public MyMultiUploader(String ...files) {
for (String f : files ) {
Uploader u = (Uploader)getUploaderInstance();
IFileInput i = u.getFileInput();
IUploadStatus s = u.getStatusWidget();
i.setVisible(false);
s.setVisible(true);
u.getForm().removeFromParent();
u.setServletPath("whatever");
s.setFileName(f);
s.setStatus(Status.SUCCESS);
final String name = f;
s.addCancelHandler(new UploadCancelHandler() {
public void onCancel() {
Window.alert("Cancel " + name);
}
});
panel.add(u);
}
panel.add(multiuploader);
}
}
}
于 2013-02-14T17:58:55.320 回答
0
我认为我们需要在 servlet 中添加文件
Hashtable<String, String> receivedContentTypes = new Hashtable<String, String>();
/**
* Maintain a list with received files and their content types.
*/
Hashtable<String, File> receivedFiles = new Hashtable<String, File>();
但我不知道怎么...
于 2013-02-15T06:56:26.940 回答