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/09/12 16:13:36 UTC

[jira] Commented: (WICKET-2864) FileUpload and Wizard

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