[ 
https://issues.apache.org/jira/browse/WICKET-2864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Igor Vaynberg resolved WICKET-2864.
-----------------------------------

    Resolution: Invalid

i have just added the following javadoc to FileUploadField

 * <p>
 * <strong>NOTE</strong>The model of this component is reset with {...@code 
null} at the end of the
 * request because {...@link FileUpload} instances do not survive across 
requests since the input
 * streams they point to will be closed. Because of this, the {...@link 
FileUpload} instance should be
 * processed within the same request as the form containing it was submitted.
 * </p>

what you should so is in setFu(FileUpload) copy the file to some temporary 
location and store the path to the file in the dto so you can access it at the 
end of the wizard. cheers.

> 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.

Reply via email to