[ https://issues.apache.org/jira/browse/WICKET-2864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908475#action_12908475 ]
Martin Hubert commented on WICKET-2864: --------------------------------------- Hi Igor, now i found out that the onDetach() method of the FileUploadField class is the source of this problem. Unlike other Form Components it removes itself from the Model. if (getModel() != null) { getModel().setObject(null); } if this is a bug we should file a new ticket. if it is a feature, it should be well documented. > FileUpload and Wizard > --------------------- > > Key: WICKET-2864 > URL: https://issues.apache.org/jira/browse/WICKET-2864 > Project: Wicket > Issue Type: Bug > Components: wicket-extensions > Affects Versions: 1.4.8 > Environment: ubuntu10.4 / jdk1.6.0_20 / tomcat-6.0.20 / Eclipse 3.5.2 > Reporter: Martin Hubert > Assignee: Igor Vaynberg > Attachments: WicketWizardTest.tgz > > > FileUploadField is always null if not in last WizardStep. > public TestWizard() { > ... > model.add(new StepFu()); > model.add(new StepTxt()); > ... > } > works, but for > public TestWizard() { > ... > model.add(new StepTxt()); > model.add(new StepFu()); > ... > } > the FileUpload ist always null. > === > import java.io.Serializable; > import org.apache.wicket.extensions.wizard.Wizard; > import org.apache.wicket.extensions.wizard.WizardModel; > import org.apache.wicket.extensions.wizard.WizardStep; > import org.apache.wicket.markup.html.form.TextField; > import org.apache.wicket.markup.html.form.upload.FileUpload; > import org.apache.wicket.markup.html.form.upload.FileUploadField; > import org.apache.wicket.model.CompoundPropertyModel; > public class TestWizard extends Wizard { > private static final long serialVersionUID = 1L; > public TestWizard(String id) { > super(id); > TestBean bean = new TestBean(); > setDefaultModel(new CompoundPropertyModel<TestBean>(bean)); > WizardModel model = new WizardModel(); > model.add(new StepFu()); > model.add(new StepTxt()); > init(model); > getForm().setMultiPart(true); > } > public class TestBean implements Serializable { > private static final long serialVersionUID = 1L; > private String _text1; > private FileUpload _fu; > public String getText1() { > return _text1; > } > public void setText1(String text1) { > _text1 = text1; > } > public FileUpload getFu() { > return _fu; > } > public void setFu(FileUpload fu) { > _fu = fu; > } > } > > private final class StepTxt extends WizardStep { > private static final long serialVersionUID = 1L; > public StepTxt() { > add(new TextField<String>("text1")); > } > } > > private final class StepFu extends WizardStep { > private static final long serialVersionUID = 1L; > public StepFu() { > add(new FileUploadField("fu")); > } > } > > @Override > public void onFinish() { > TestBean bean = (TestBean) getDefaultModelObject(); > > System.out.println("*******************************************"); > System.out.println("text1: " + bean.getText1()); > System.out.println("fu: " + bean.getFu()); > > System.out.println("*******************************************"); > setResponsePage(getApplication().getHomePage()); > } > } > === > Tested with wicket-1.4.7 and wicket-1.4.8 -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.