You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Martin Hubert (JIRA)" <ji...@apache.org> on 2010/05/09 11:52:50 UTC
[jira] Created: (WICKET-2864) FileUpload and Wizard
FileUpload and Wizard
---------------------
Key: WICKET-2864
URL: https://issues.apache.org/jira/browse/WICKET-2864
Project: Wicket
Issue Type: Bug
Components: wicket-examples
Affects Versions: 1.4.8
Environment: ubuntu10.4 / jdk1.6.0_20 / tomcat-6.0.20 / Eclipse 3.5.2
Reporter: Martin Hubert
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.
[jira] Reopened: (WICKET-2864) FileUpload and Wizard
Posted by "Martin Hubert (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Hubert reopened WICKET-2864:
-----------------------------------
Sorry, still not working.
I will attach my full test project.
> 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
>
> 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.
[jira] Updated: (WICKET-2864) FileUpload and Wizard
Posted by "Martin Hubert (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Hubert updated WICKET-2864:
----------------------------------
Attachment: WicketWizardTest.tgz
I use the wicket-1.4 snapshot from yesterday (28 Aug)
> 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.
[jira] Resolved: (WICKET-2864) FileUpload and Wizard
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Igor Vaynberg resolved WICKET-2864.
-----------------------------------
Assignee: Igor Vaynberg
Resolution: Cannot Reproduce
i fixed a problem with wizard and fileuploads recently. please try with latest snapshot and if still doesnt work reopen and attach a proper quickstart.
> 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
>
> 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.
[jira] Updated: (WICKET-2864) FileUpload and Wizard
Posted by "Martin Hubert (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2864?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Martin Hubert updated WICKET-2864:
----------------------------------
Component/s: wicket-extensions
(was: wicket-examples)
wicket-extensions not wicket-examples
> 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
>
> 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.
[jira] Commented: (WICKET-2864) FileUpload and Wizard
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908474#action_12908474 ]
Igor Vaynberg commented on WICKET-2864:
---------------------------------------
javadoc from 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>
> 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.
[jira] Commented: (WICKET-2864) FileUpload and Wizard
Posted by "Martin Hubert (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Commented: (WICKET-2864) FileUpload and Wizard
Posted by "Martin Hubert (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/WICKET-2864?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908473#action_12908473 ]
Martin Hubert commented on WICKET-2864:
---------------------------------------
Ok, thanks. With this workaround i can use FileUpload in a Wizard.
But I see some funny behavior.setFu is called twice when i press next. The first call sets a FileUpload object the second call sets NULL. The first call occurs before WizardStep.applyState() which seems to be correct, the second call occurs after applyState().
Other setters like setText1 are only called once before applyState().
> 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.
[jira] Resolved: (WICKET-2864) FileUpload and Wizard
Posted by "Igor Vaynberg (JIRA)" <ji...@apache.org>.
[ 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.