I ve got a weird problem with GWT and HTML forms.
I ve made a simple FormPanel with 3 basic elements in it: FileUpload for image uploading, TextBox for the name of the image and Button for submit. Everything works (I can save the image server-side at least) except that whatever I type in the input field, it does not have a value, i.e. in Chrome s Inspect Element I clearly see that it has no value="..." field.
Why is this happening and how do I fix it? I can t save the name if it doesn t have any.
Edit:
private final FlowPanel imagePanel = new FlowPanel();
private final FormPanel form = new FormPanel();
private final FileUpload fileUpload = new FileUpload();
private final Button submitButton = new Button("Upload");
private final TextBox fileName = new TextBox();
private final HorizontalPanel hp = new HorizontalPanel();
private final VerticalPanel vp = new VerticalPanel();
public void onModuleLoad()
{
vp.add(fileUpload);
hp.add(fileName);
hp.add(submitButton);
vp.add(hp);
form.add(vp);
form.setEncoding(FormPanel.ENCODING_MULTIPART);
form.setMethod(FormPanel.METHOD_POST);
form.setAction("/upload");
fileUpload.setName("upload"); // image identifier, used in upload handler
fileName.setName("fileName");
fileName.setValue("Enter file name");
fileName.setMaxLength(40);
fileName.addStyleName("fileNameHint");
RootPanel.get("uploadBar").add(form);
RootPanel.get("thumbnails").add(imagePanel);
}
这是除活动处理者外的所有布局。 提交文件时发生的所有情况都是对文件上载价值进行检查,以便允许文件延期。