Description
If a form has FileUploadField and versioned, Page, on which the form is, will be expired at second post of the form.
run a attached project file. In this sample program, onSubmit() method of Form always displays same page with an error message. Post the form again, then page will be expired.
This problem will occur if a versioned property of FileUploadField is true. If the property is false, this problem never occurs.
If you use setVersioned() method of Form with FileUploadField, the 'versioned' property of the FileUploadField becomes true automatically, so this problem easily occurs in the timing not anticipated.
I noticed version number of page up twice on 'detach' time, if FileUploadField is versioned.
I expect, this problem might occur only for components with isMultiPart() == true, although I could not found the evidence.
If so, 'versioned' property of such component must never become true. In addition, setVersioned() method of Form component should check children are Multipart or not, like below.
@Override
public final Component setVersioned(final boolean isVersioned)
{
super.setVersioned(isVersioned);
// Search for FormComponents like TextField etc.
visitFormComponents(new FormComponent.AbstractVisitor()
{
@Override
public void onFormComponent(final FormComponent<?> formComponent)
{
if(!formComponent.isMultiPart())
}
});
return this;
}