My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.ibm.sampledb.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FileUpload;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.ibm.sampledb.shared.IResourceType;

public class UploadFile extends Composite {

private static UploadFileUiBinder uiBinder = GWT
.create(UploadFileUiBinder.class);

interface UploadFileUiBinder extends UiBinder<Widget, UploadFile> {
}

public UploadFile() {
initWidget(uiBinder.createAndBindUi(this));
actionClose = null;
}

private FormPanel f() {
return (FormPanel) this.getWidget();
}

@UiField
TextBox comment;
@UiField
FileUpload fileupload;
@UiField
Hidden empname;
@UiField
Button submit;

private final IAction actionClose;

public UploadFile(String empNo, final IAction actionClose) {
this.actionClose = actionClose;
initWidget(uiBinder.createAndBindUi(this));
String action = GWT.getHostPageBaseURL() + "/upLoadHandler";
f().setAction(action);
f().setEncoding(FormPanel.ENCODING_MULTIPART);
f().setMethod(FormPanel.METHOD_POST);
empname.setName(IResourceType.EMPNO);
empname.setValue(empNo);
comment.setName(IResourceType.COMMENT);
fileupload.setName(IResourceType.FILE);
SubmitCompleteHandler ha = new SubmitCompleteHandler() {

@Override
public void onSubmitComplete(SubmitCompleteEvent event) {
String res = event.getResults();
if (res.contains(IResourceType.ERRORSUBMIT)) {
Window.alert(M.getM().SubmitError());
} else {
Window.alert(M.getM().SubmitCompleted());
}
actionClose.execute();
}
};
f().addSubmitCompleteHandler(ha);
}

@UiHandler("submit")
void onClick(ClickEvent e) {
String filename = fileupload.getFilename();
if (filename.equals("")) {
Window.alert(M.getM().EnterFileName());
return;
}
if (!Window.confirm(M.getM().SubmitQuestion())) {
return;
}
f().submit();
}

@UiHandler("resign")
void onResignClick(ClickEvent event) {
actionClose.execute();
}
}

Change log

r407 by stanislawbartkowski on Jul 6, 2011   Diff
new version with attachments
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 2586 bytes, 92 lines

File properties

svn:mime-type
text/plain
Powered by Google Project Hosting