FileUploadField component blocks component and form submission when an empty
file is selected
---------------------------------------------------------------------------------------------
Key: WICKET-2523
URL: https://issues.apache.org/jira/browse/WICKET-2523
Project: Wicket
Issue Type: Bug
Components: wicket
Affects Versions: 1.4-RC1
Environment: Operating system: Microsoft Windows XP Media Center
Edition Version 2002 Service Pack 3
NetBeans development, build and run environment is:
Product Version: NetBeans IDE 6.7 (Build 200906241340)
Java: 1.6.0_15; Java HotSpot(TM) Client VM 14.1-b02
System: Windows XP version 5.1 running on x86; Cp1252; en_GB (nb)
Userdir: C:\Documents and Settings\Ian\.netbeans\6.7
Wicket plug-ins used:
Wicket as a library
Version: 1.4
Description: Wicket 1.4 RC1 Library
Wicket Support:
Version: 0.15
Wicket File Templates:
Version: 1.1
Web server: Apache Tomcat 6.0.18
Web browser: Mozilla Firefox (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB;
rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)).
Note: when using Microsoft Internet Explorer 8 (version 8.0.6001.18702) all
works fine and an empty file does not block processing in any way. This issue
submission is based on using the above Firefox browser only.
Reporter: Ian Marshall
Priority: Minor
I have a FileUploadField component in a form. When a file of size zero is
selected using the component's integral "Browse..." button, and then one of the
owning form's submit buttons is clicked, neither that button's nor the form's
overridden onSubmit() methods is called. The form becomes unsubmissible.
Something happens on the browser (Mozilla Firefox) since the waiting dots
appear for a brief moment, but no change is apparent to me on the browser.
If a non-empty file is subsequently selected using the FileUploadField
component's "Browse..." button, then normal onSubmit() functionality is
restored.
The method Form#onFormSubmitted() method is not called upon clicking a submit
button if the FileUploadField field has an empty file selected.
HTML code
----------
<form wicket:id="frmForm">
<input wicket:id="fufUploadImage" type="file" size="40" tabindex="3"/>
<input type="submit" wicket:id="btnUpload" value="<--- Upload file"
tabindex="4"/>
<input type="submit" wicket:id="btnOK" value="OK" tabindex="101"/>
<input type="submit" wicket:id="btnCancel" value="Cancel" tabindex="102"/>
</form>
Java code
----------
public final class PageItem extends PageBase \\ PageBase descends from
WebPage
{
private static final long serialVersionUID = 1L;
public enum ItemMode
{
Create, Edit, View, Delete
};
private class PageItemData implements Serializable
{
private static final long serialVersionUID = 1L;
public FileUpload fufUploadImage = null;
...
public PageItemData()
{
// This initialisation is required by the Serializable interface
fufUploadImage = null;
...
}
}
private static final Bytes G_BY_MAX_SIZE_FILE_UPLOAD = Bytes.megabytes(1);
private PageItemData g_pidData = null;
public PageItem()
{
this(ItemMode.Create, null);
}
@SuppressWarnings({"fallthrough", "unchecked"})
private PageItem(final ItemMode imMode, PageItemData pidData)
{
super();
if (pidData != null)
g_pidData = pidData;
else
g_pidData = new PageItemData();
Form frmForm = new Form("frmForm")
{
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit()
{
...
//
// Persist the item data here...
//
}
};
frmForm.setMultiPart(true); // To enable file uploading
frmForm.setMaxSize(G_BY_MAX_SIZE_FILE_UPLOAD);
frmForm.setModel(new CompoundPropertyModel(g_pidData));
add(frmForm);
final FileUploadField fufUploadImage =
new FileUploadField("fufUploadImage");
frmForm.add(fufUploadImage);
Button btnUpload = new Button("btnUpload")
{
private static final long serialVersionUID = 1L;
@Override
public void onSubmit()
{
...
}
};
btnUpload.setDefaultFormProcessing(false);
frmForm.add(btnUpload);
Button btnOK = new Button("btnOK");
frmForm.add(btnOK);
Button btnCancel = new Button("btnCancel")
{
private static final long serialVersionUID = 1L;
@Override
public void onSubmit()
{
...
setResponsePage(PageHome.class);
}
};
btnCancel.setDefaultFormProcessing(false);
frmForm.add(btnCancel);
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.