You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2012/10/23 14:59:12 UTC

[2/2] git commit: Tinkering with upload progress and Ajax

Tinkering with upload progress and Ajax

Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/9782f040
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/9782f040
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/9782f040

Branch: refs/heads/master
Commit: 9782f040be131a965f952a74338e3274b81f9bc7
Parents: 266b591
Author: svenmeier <sv...@apache.org>
Authored: Tue Oct 23 14:49:34 2012 +0200
Committer: svenmeier <sv...@apache.org>
Committed: Tue Oct 23 14:49:34 2012 +0200

----------------------------------------------------------------------
 .../examples/ajax/builtin/FileUploadPage.html      |    3 +-
 .../examples/ajax/builtin/FileUploadPage.java      |   26 ++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/9782f040/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.html
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.html b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.html
index c6e9eff..9351d4c 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.html
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.html
@@ -8,7 +8,8 @@ Demonstrates Wicket's ability to transparently handle multipart forms via AJAX.<
 
 <form wicket:id="form">
 	Text field: <input wicket:id="text" type="text"/><br/>
-	File field: <input wicket:id="file" type="file"/> (1MB max)<br/><br/>
+	File field: <input wicket:id="file" type="file"/> (<span wicket:id="max"></span> max)<br/><br/>
+	<div wicket:id="progress"></div>
 	<input type="submit" value="Regular Submit"/> <input wicket:id="ajaxSubmit" type="button" value="Ajax Submit"/>
 </form>
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/9782f040/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java
----------------------------------------------------------------------
diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java
index 15dded6..bd4c6b9 100644
--- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java
+++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajax/builtin/FileUploadPage.java
@@ -19,13 +19,17 @@ package org.apache.wicket.examples.ajax.builtin;
 import org.apache.wicket.Component;
 import org.apache.wicket.ajax.AjaxRequestTarget;
 import org.apache.wicket.ajax.markup.html.form.AjaxButton;
+import org.apache.wicket.extensions.ajax.markup.html.form.upload.UploadProgressBar;
+import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.form.Form;
 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.markup.html.panel.FeedbackPanel;
+import org.apache.wicket.model.AbstractReadOnlyModel;
 import org.apache.wicket.model.Model;
 import org.apache.wicket.util.lang.Bytes;
+import org.apache.wicket.validation.validator.StringValidator;
 
 /**
  * Demos ajax handling of a multipart form
@@ -34,6 +38,8 @@ import org.apache.wicket.util.lang.Bytes;
  */
 public class FileUploadPage extends BasePage
 {
+	private static final long serialVersionUID = 1L;
+
 	private final FileUploadField file;
 	private final TextField<String> text;
 
@@ -48,8 +54,10 @@ public class FileUploadPage extends BasePage
 		add(feedback);
 
 		// create the form
-		Form<?> form = new Form<Void>("form")
+		final Form<?> form = new Form<Void>("form")
 		{
+			private static final long serialVersionUID = 1L;
+
 			/**
 			 * @see org.apache.wicket.markup.html.form.Form#onSubmit()
 			 */
@@ -75,13 +83,29 @@ public class FileUploadPage extends BasePage
 
 		// create a textfield to demo non-file content
 		form.add(text = new TextField<String>("text", new Model<String>()));
+		text.add(StringValidator.minimumLength(2));
 
 		// create the file upload field
 		form.add(file = new FileUploadField("file"));
 
+		form.add(new Label("max", new AbstractReadOnlyModel<String>()
+		{
+			private static final long serialVersionUID = 1L;
+
+			@Override
+			public String getObject()
+			{
+				return form.getMaxSize().toString();
+			}
+		}));
+
+		form.add(new UploadProgressBar("progress", form, file));
+
 		// create the ajax button used to submit the form
 		form.add(new AjaxButton("ajaxSubmit")
 		{
+			private static final long serialVersionUID = 1L;
+
 			@Override
 			protected void onSubmit(AjaxRequestTarget target, Form<?> form)
 			{