[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714429#comment-17714429 ] ASF subversion and git services commented on WICKET-7033: - Commit 5d2cae18df45cce2a37f6e3b592c52802f90b865 in wicket's branch refs/heads/master from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=5d2cae18df ] [WICKET-7033] add comments to code (amendment) > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714428#comment-17714428 ] ASF subversion and git services commented on WICKET-7033: - Commit 1f420dc2bfe05687093706827e4ec45d824ead79 in wicket's branch refs/heads/wicket-9.x from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=1f420dc2bf ] [WICKET-7033] add comments to code (amendment) > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714415#comment-17714415 ] ASF subversion and git services commented on WICKET-7033: - Commit ff4ebd2f20366a4c5137b661d669f86297363e4e in wicket's branch refs/heads/wicket-9.x from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=ff4ebd2f20 ] [WICKET-7033] add comments to code > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714414#comment-17714414 ] ASF subversion and git services commented on WICKET-7033: - Commit efb081e0fcce176565f50b878b4941ac6de19af5 in wicket's branch refs/heads/master from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=efb081e0fc ] [WICKET-7033] add comments to code > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714144#comment-17714144 ] ASF subversion and git services commented on WICKET-7033: - Commit fd890ccc7c787c192f308e9b4c2a64844954ce86 in wicket's branch refs/heads/master from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=fd890ccc7c ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714137#comment-17714137 ] ASF GitHub Bot commented on WICKET-7033: reiern70 closed pull request #576: [WICKET-7033] implementation of: 1) an upload field that allows uploa… URL: https://github.com/apache/wicket/pull/576 > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714136#comment-17714136 ] ASF GitHub Bot commented on WICKET-7033: reiern70 merged PR #571: URL: https://github.com/apache/wicket/pull/571 > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714135#comment-17714135 ] ASF subversion and git services commented on WICKET-7033: - Commit 791784f6abe2d094605957e49dd73e5844ed8429 in wicket's branch refs/heads/wicket-9.x from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=791784f6ab ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17714134#comment-17714134 ] ASF subversion and git services commented on WICKET-7033: - Commit 791784f6abe2d094605957e49dd73e5844ed8429 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=791784f6ab ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17713899#comment-17713899 ] ASF subversion and git services commented on WICKET-7033: - Commit 3c9c69185fd13e183375f860ce4ddfee6e8fe71d in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=3c9c69185f ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17713894#comment-17713894 ] ASF subversion and git services commented on WICKET-7033: - Commit 79f9ba8857e71f6877ae6448c57385213f7efd00 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=79f9ba8857 ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17713468#comment-17713468 ] ASF subversion and git services commented on WICKET-7033: - Commit 12425da3fbf3376ff15886338b0d0ff28e2058f3 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=12425da3fb ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17713463#comment-17713463 ] ASF subversion and git services commented on WICKET-7033: - Commit b51989caad77a3e62ced6f76465262ad49e9ad89 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=b51989caad ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712994#comment-17712994 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #571: URL: https://github.com/apache/wicket/pull/571#issuecomment-1511031910 This still needs some more work to be as clean as possible > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712873#comment-17712873 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1168125179 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/AbstractFileUploadResource.java: ## @@ -0,0 +1,223 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.util.lang.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.openjson.JSONObject; + +/** + * The resource that handles the file uploads. + * Reads the file items from the request parameters and uses {@link IUploadsFileManager} + * to store them. + * Additionally, cares about the response's content type and body. + * + * This code was adapted from + * + * https://github.com/martin-g/blogs/blob/master/file-upload/src/main/java/com/mycompany/fileupload/AbstractFileUploadResource.java;>AbstractFileUploadResource.java + * + * The main difference is that there some JQuery plugin is used at client side (and it supports multiple uploads + + * some UI allowing to delete/preview files and so on). + * Here we are just using plain jQuery code at client side to upload a single file. + */ +public abstract class AbstractFileUploadResource extends AbstractResource +{ + private static final Logger LOG = LoggerFactory.getLogger(AbstractFileUploadResource.class); + + public static final String PARAM_NAME = "WICKET-FILE-UPLOAD"; + + /** +* This resource is usually an application singleton. Thus, client side pass +* to the resource a unique ID identifying the upload field performing the upload. +* The upload file makes sure this is a unique identifier at application level, See +* {@link FileUploadToResourceField#generateAUniqueApplicationWiseId()}. So that, there are no clashes between +* different users/pages/sessions performing an upload. +*/ + public static final String UPLOAD_ID = "uploadId"; + /** +* i18n key for case no files were selected. +*/ + public static final String NO_FILE_SELECTED = "wicket.no.files.selected"; + /** +* i18n key for the case selcted files exceed size limit. +*/ + public static final String REQUEST_SIZE_LIMIT_EXCEEDED = "wicket.multipart.size.exceeded"; + + private final IUploadsFileManager fileManager; + + public AbstractFileUploadResource(IUploadsFileManager fileManager) + { + this.fileManager = fileManager; + } + + /** +* Reads and stores the uploaded files +* +* @param attributes +*Attributes +* @return ResourceResponse +*/ + @Override + protected ResourceResponse newResourceResponse(Attributes attributes) + { + final ResourceResponse resourceResponse = new ResourceResponse(); + + final ServletWebRequest webRequest = (ServletWebRequest) attributes.getRequest(); + + // get the ID of the upload field (it should be unique per application) + String uploadId = webRequest.getRequestParameters().getParameterValue(UPLOAD_ID).toString("resource"); + + try + { + MultipartServletWebRequest multiPartRequest =
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712871#comment-17712871 ] ASF GitHub Bot commented on WICKET-7033: solomax commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1168122329 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/AbstractFileUploadResource.java: ## @@ -0,0 +1,223 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletResponse; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.util.lang.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.openjson.JSONObject; + +/** + * The resource that handles the file uploads. + * Reads the file items from the request parameters and uses {@link IUploadsFileManager} + * to store them. + * Additionally, cares about the response's content type and body. + * + * This code was adapted from + * + * https://github.com/martin-g/blogs/blob/master/file-upload/src/main/java/com/mycompany/fileupload/AbstractFileUploadResource.java;>AbstractFileUploadResource.java + * + * The main difference is that there some JQuery plugin is used at client side (and it supports multiple uploads + + * some UI allowing to delete/preview files and so on). + * Here we are just using plain jQuery code at client side to upload a single file. + */ +public abstract class AbstractFileUploadResource extends AbstractResource +{ + private static final Logger LOG = LoggerFactory.getLogger(AbstractFileUploadResource.class); + + public static final String PARAM_NAME = "WICKET-FILE-UPLOAD"; + + /** +* This resource is usually an application singleton. Thus, client side pass +* to the resource a unique ID identifying the upload field performing the upload. +* The upload file makes sure this is a unique identifier at application level, See +* {@link FileUploadToResourceField#generateAUniqueApplicationWiseId()}. So that, there are no clashes between +* different users/pages/sessions performing an upload. +*/ + public static final String UPLOAD_ID = "uploadId"; + /** +* i18n key for case no files were selected. +*/ + public static final String NO_FILE_SELECTED = "wicket.no.files.selected"; + /** +* i18n key for the case selcted files exceed size limit. +*/ + public static final String REQUEST_SIZE_LIMIT_EXCEEDED = "wicket.multipart.size.exceeded"; + + private final IUploadsFileManager fileManager; + + public AbstractFileUploadResource(IUploadsFileManager fileManager) + { + this.fileManager = fileManager; + } + + /** +* Reads and stores the uploaded files +* +* @param attributes +*Attributes +* @return ResourceResponse +*/ + @Override + protected ResourceResponse newResourceResponse(Attributes attributes) + { + final ResourceResponse resourceResponse = new ResourceResponse(); + + final ServletWebRequest webRequest = (ServletWebRequest) attributes.getRequest(); + + // get the ID of the upload field (it should be unique per application) + String uploadId = webRequest.getRequestParameters().getParameterValue(UPLOAD_ID).toString("resource"); + + try + { + MultipartServletWebRequest multiPartRequest = webRequest.newMultipartWebRequest(getMaxSize(),
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712358#comment-17712358 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #576: URL: https://github.com/apache/wicket/pull/576#issuecomment-1508401859 Branch name is worng but PR is correct :-) > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712356#comment-17712356 ] ASF subversion and git services commented on WICKET-7033: - Commit 11b6adb408af8df43e73160f91c6c4939cd015ea in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=11b6adb408 ] [WICKET-7033] fix link to page in home page > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712354#comment-17712354 ] ASF subversion and git services commented on WICKET-7033: - Commit fa8ae744a761f2cdeccd4a130f41a82b1041f031 in wicket's branch refs/heads/bugix/reiern70/WICKET-7037-master from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=fa8ae744a7 ] [WICKET-7033] fix link to page in home page > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712342#comment-17712342 ] ASF GitHub Bot commented on WICKET-7033: bitstorm commented on PR #571: URL: https://github.com/apache/wicket/pull/571#issuecomment-1508358847 > @bitstorm Shall I wait till you cut release for merging? Or can I merge and you cout release from previosu commit? @reiern70 In the end I think it's better waiting after 9.13.0 is officially released. I will start the vote in few ours. Than I will merge your PR into 9.x branch. > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712317#comment-17712317 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #571: URL: https://github.com/apache/wicket/pull/571#issuecomment-1508289531 @bitstorm Shall I wait till you cut release for merging? Or can I merge and you cout release from previosu commit? > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712287#comment-17712287 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #576: URL: https://github.com/apache/wicket/pull/576#issuecomment-1508213299 This is the correspoding for https://github.com/apache/wicket/pull/571 but to master > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712286#comment-17712286 ] ASF GitHub Bot commented on WICKET-7033: reiern70 opened a new pull request, #576: URL: https://github.com/apache/wicket/pull/576 …ding files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712272#comment-17712272 ] ASF subversion and git services commented on WICKET-7033: - Commit 0b36a50428a417e933988435599f987f3c78452d in wicket's branch refs/heads/bugix/reiern70/WICKET-7037-master from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=0b36a50428 ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712249#comment-17712249 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #571: URL: https://github.com/apache/wicket/pull/571#issuecomment-1508093631 Squashed all commits and reabsed on top of 9.x + force pushed. > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712248#comment-17712248 ] ASF subversion and git services commented on WICKET-7033: - Commit 9d5bb381559392993e450e1889760ff0915f2e74 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=9d5bb38155 ] [WICKET-7033] implementation of: 1) an upload field that allows uploading files into to a mounted resource, 2) a reusable mounted resource that process uploads and 3) adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712243#comment-17712243 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1166441080 ## wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js: ## @@ -55,24 +58,39 @@ if (displayprogress) { this.setPercent(0); this.setStatus(this.initialStatus); - Wicket.$(this.statusid).removeAttribute('hidden'); - Wicket.$(this.barid).removeAttribute('hidden'); + var $statusId = Wicket.$(this.statusid); + if ($statusId != null) { + Wicket.DOM.show($statusId); + } + var $barid = Wicket.$(this.barid) Review Comment: > Missing a semicolon, it makes jshint fail. FIxed > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712242#comment-17712242 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #571: URL: https://github.com/apache/wicket/pull/571#issuecomment-1508088057 Fixed that warning, > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712236#comment-17712236 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1166419621 ## wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js: ## @@ -55,24 +58,39 @@ if (displayprogress) { this.setPercent(0); this.setStatus(this.initialStatus); - Wicket.$(this.statusid).removeAttribute('hidden'); - Wicket.$(this.barid).removeAttribute('hidden'); + var $statusId = Wicket.$(this.statusid); + if ($statusId != null) { + Wicket.DOM.show($statusId); + } + var $barid = Wicket.$(this.barid) Review Comment: > Understood, thanks for the clarifications! Pleasure. Initialy I had those and **maven clean failed**. I juess this is to make sure our JavaScript works on older browsers too > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712235#comment-17712235 ] ASF GitHub Bot commented on WICKET-7033: solomax commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1166414916 ## wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js: ## @@ -55,24 +58,39 @@ if (displayprogress) { this.setPercent(0); this.setStatus(this.initialStatus); - Wicket.$(this.statusid).removeAttribute('hidden'); - Wicket.$(this.barid).removeAttribute('hidden'); + var $statusId = Wicket.$(this.statusid); + if ($statusId != null) { + Wicket.DOM.show($statusId); + } + var $barid = Wicket.$(this.barid) Review Comment: Understood, thanks for the clarifications! > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712231#comment-17712231 ] ASF subversion and git services commented on WICKET-7033: - Commit 84a9f8ff1551b5c94ef2c6d0a789bf9c46fd9e9b in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=84a9f8ff15 ] [WICKET-7033] clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712228#comment-17712228 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1166400295 ## wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js: ## @@ -55,24 +58,39 @@ if (displayprogress) { this.setPercent(0); this.setStatus(this.initialStatus); - Wicket.$(this.statusid).removeAttribute('hidden'); - Wicket.$(this.barid).removeAttribute('hidden'); + var $statusId = Wicket.$(this.statusid); + if ($statusId != null) { + Wicket.DOM.show($statusId); + } + var $barid = Wicket.$(this.barid) Review Comment: > Just curious: why `var` is used and not `let` and `const`? If you use let and const then the project will not build. I think there is some logic compiling and minimizing javascript and there are some settings for a target version of JavaScript that does not allow const and let. Only vars... > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17712229#comment-17712229 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #571: URL: https://github.com/apache/wicket/pull/571#issuecomment-1508050333 > Once Maven build is happy I'm ok merging with 9.x . I don't see any reason to postpone it Locally it builds. > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711935#comment-17711935 ] ASF GitHub Bot commented on WICKET-7033: solomax commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1165669069 ## wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js: ## @@ -55,24 +58,39 @@ if (displayprogress) { this.setPercent(0); this.setStatus(this.initialStatus); - Wicket.$(this.statusid).removeAttribute('hidden'); - Wicket.$(this.barid).removeAttribute('hidden'); + var $statusId = Wicket.$(this.statusid); + if ($statusId != null) { + Wicket.DOM.show($statusId); + } + var $barid = Wicket.$(this.barid) Review Comment: Just curious: why `var` is used and not `let` and `const`? > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711893#comment-17711893 ] ASF GitHub Bot commented on WICKET-7033: bitstorm commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1165548506 ## wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js: ## @@ -55,24 +58,39 @@ if (displayprogress) { this.setPercent(0); this.setStatus(this.initialStatus); - Wicket.$(this.statusid).removeAttribute('hidden'); - Wicket.$(this.barid).removeAttribute('hidden'); + var $statusId = Wicket.$(this.statusid); + if ($statusId != null) { + Wicket.DOM.show($statusId); + } + var $barid = Wicket.$(this.barid) Review Comment: Missing a semicolon, it makes jshint fail. > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711828#comment-17711828 ] ASF subversion and git services commented on WICKET-7033: - Commit 73873ada6cfd5dd69acfabb6d49f230729f474d5 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=73873ada6c ] [WICKET-7033] clientBeforeSendCallBack call back > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711382#comment-17711382 ] ASF subversion and git services commented on WICKET-7033: - Commit 15faabf9ea79f611bc0a1ffb5ea77e65a3c26b70 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=15faabf9ea ] [WICKET-7033] license > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711377#comment-17711377 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #571: URL: https://github.com/apache/wicket/pull/571#issuecomment-1505236951 @martin-g Many thanks again for your review. I have addressed ou comments. Could you do another review pelase? > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711376#comment-17711376 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1164102780 ## wicket-examples/src/main/java/org/apache/wicket/examples/upload/UploadApplication.java: ## @@ -55,9 +61,22 @@ protected void init() // Ensure folder exists uploadFolder.mkdirs(); + uploadsFileManager = new FolderUploadsFileManager(uploadFolder); + + mountResource("/uploads", FileUploadResourceReference.createNewInstance(uploadsFileManager, Bytes.megabytes(100))); Review Comment: Done > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711371#comment-17711371 ] ASF subversion and git services commented on WICKET-7033: - Commit 50e15cb81b51465b401ba3d9ee3eee0c4d9d5a4c in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=50e15cb81b ] [WICKET-7033] restrict upload size > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711369#comment-17711369 ] ASF subversion and git services commented on WICKET-7033: - Commit ca95b9ad3a03d93ef6d6f7ea554eda97b5fd5c79 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=ca95b9ad3a ] [WICKET-7033] restrict upload size > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711366#comment-17711366 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1164094593 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711364#comment-17711364 ] ASF subversion and git services commented on WICKET-7033: - Commit f26f968df30e9a1db3f4d50d25e7400af12666f6 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=f26f968df3 ] [WICKET-7033] improve examples > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711346#comment-17711346 ] ASF subversion and git services commented on WICKET-7033: - Commit 19d6ff5dcd54c62657c68afc9d9cd2170c3e592b in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=19d6ff5dcd ] [WICKET-7033] javadoc > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711345#comment-17711345 ] ASF subversion and git services commented on WICKET-7033: - Commit 570d41632dba3e8599d68944b52594f9058e2080 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=570d41632d ] [WICKET-7033] javadoc > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711342#comment-17711342 ] ASF subversion and git services commented on WICKET-7033: - Commit d86b65f6c3e6a83f71c568456e20aabd0d7b3c21 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=d86b65f6c3 ] [WICKET-7033] clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711341#comment-17711341 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1164023647 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.js: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +;(function (undefined) { + +'use strict'; + +if (typeof(Wicket.FileUploadToResourceField) === 'object') { +return; +} + +Wicket.FileUploadToResourceField = function (settings, clientSideSuccessCallBack, clientSideCancelCallBack, connectionErrorCallBack) +{ +this.inputName = settings.inputName; +this.input = document.getElementById(this.inputName); +this.resourceUrl = settings.resourceUrl + "?uploadId=" + this.inputName; +this.ajaxCallBackUrl = settings.ajaxCallBackUrl; +this.clientSideSuccessCallBack = clientSideSuccessCallBack; +this.clientSideCancelCallBack = clientSideCancelCallBack; +this.connectionErrorCallBack = connectionErrorCallBack; +} + +Wicket.FileUploadToResourceField.prototype.upload = function() +{ +// we add the files to a FormData object. +var formData = new FormData(); +var totalfiles = this.input.files.length; +for (var index = 0; index < totalfiles; index++) { +formData.append("FILE-UPLOAD",this.input.files[index]); +} +// pass the input name to knw where to store files at server side. +formData.append("uploadId", this.inputName); +var self = this; +// we use jQuery to post the file to the resource (this.resourceUrl) +// and we keep a reference to the request in order to be able +// to cancel the upload +this.xhr = $.ajax({ +url: this.resourceUrl, +type: "POST", +data: formData, +processData: false, +contentType: false, +success: function (res) { +// do clean up on success +self.clientSideSuccessCallBack(); +if (res.error) { +var ep = {'success': false, 'errorMessage': res.errorMessage}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +self.connectionErrorCallBack(res); +} else { +var ep = {'success': true, 'filesInfo': JSON.stringify(res)}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +} +}, +error: function (jqXHR, textStatus, errorThrown) { +if (textStatus === "abort") { +// user aborted the upload. +self.clientSideCancelCallBack(); +var ep = {'success': false, 'errorMessage': 'upload.canceled'}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +} else if (textStatus === "error"){ +var ep = {'success': false, 'errorMessage': errorThrown}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +self.connectionErrorCallBack(); +} else if (textStatus === "parsererror"){ +// this error will only happen is generated JSON at server side is faulty +var data = jqXHR.responseText; +Wicket.Log.log(data); +} +} +}); +} + +// cancel the upload +Wicket.FileUploadToResourceField.prototype.cancel = function () { +// we have a reference to the request we can cancel it. +if (this.xhr) { +this.xhr.abort(); +Wicket.Log.log("upload canceled!"); +delete (this.xhr); +} else { +Wicket.Log.log("Too late to cancel: upload already finished."); +} Review Comment: Done. > add support to uploading to a resource >
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711339#comment-17711339 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1164016716 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.js: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +;(function (undefined) { + +'use strict'; + +if (typeof(Wicket.FileUploadToResourceField) === 'object') { +return; +} + +Wicket.FileUploadToResourceField = function (settings, clientSideSuccessCallBack, clientSideCancelCallBack, connectionErrorCallBack) +{ +this.inputName = settings.inputName; +this.input = document.getElementById(this.inputName); +this.resourceUrl = settings.resourceUrl + "?uploadId=" + this.inputName; +this.ajaxCallBackUrl = settings.ajaxCallBackUrl; +this.clientSideSuccessCallBack = clientSideSuccessCallBack; +this.clientSideCancelCallBack = clientSideCancelCallBack; +this.connectionErrorCallBack = connectionErrorCallBack; +} + +Wicket.FileUploadToResourceField.prototype.upload = function() +{ +// we add the files to a FormData object. +var formData = new FormData(); +var totalfiles = this.input.files.length; +for (var index = 0; index < totalfiles; index++) { +formData.append("FILE-UPLOAD",this.input.files[index]); +} +// pass the input name to knw where to store files at server side. Review Comment: Done > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711338#comment-17711338 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1164016443 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711337#comment-17711337 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1164016134 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711329#comment-17711329 ] ASF subversion and git services commented on WICKET-7033: - Commit ea1a380ba86863a0f8d56d6d3fa78f562a05a912 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=ea1a380ba8 ] [WICKET-7033] clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711325#comment-17711325 ] ASF subversion and git services commented on WICKET-7033: - Commit 73d0e775947b8a013ff3721ea42ae05736f2e91c in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=73d0e77594 ] [WICKET-7033] clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711326#comment-17711326 ] ASF subversion and git services commented on WICKET-7033: - Commit 546f54a60c1d14bafe8669576deb0efff196b1a3 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=546f54a60c ] [WICKET-7033] clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711324#comment-17711324 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163995790 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711323#comment-17711323 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163995205 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711319#comment-17711319 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163990567 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711318#comment-17711318 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163989875 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711317#comment-17711317 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163987329 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711316#comment-17711316 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163986445 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.js: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +;(function (undefined) { + +'use strict'; + +if (typeof(Wicket.FileUploadToResourceField) === 'object') { +return; +} + +Wicket.FileUploadToResourceField = function (settings, clientSideSuccessCallBack, clientSideCancelCallBack, connectionErrorCallBack) +{ +this.inputName = settings.inputName; +this.input = document.getElementById(this.inputName); +this.resourceUrl = settings.resourceUrl + "?uploadId=" + this.inputName; +this.ajaxCallBackUrl = settings.ajaxCallBackUrl; +this.clientSideSuccessCallBack = clientSideSuccessCallBack; +this.clientSideCancelCallBack = clientSideCancelCallBack; +this.connectionErrorCallBack = connectionErrorCallBack; +} + +Wicket.FileUploadToResourceField.prototype.upload = function() +{ +// we add the files to a FormData object. +var formData = new FormData(); +var totalfiles = this.input.files.length; +for (var index = 0; index < totalfiles; index++) { +formData.append("FILE-UPLOAD",this.input.files[index]); +} +// pass the input name to knw where to store files at server side. +formData.append("uploadId", this.inputName); +var self = this; +// we use jQuery to post the file to the resource (this.resourceUrl) +// and we keep a reference to the request in order to be able +// to cancel the upload +this.xhr = $.ajax({ +url: this.resourceUrl, +type: "POST", +data: formData, +processData: false, +contentType: false, +success: function (res) { +// do clean up on success +self.clientSideSuccessCallBack(); +if (res.error) { +var ep = {'success': false, 'errorMessage': res.errorMessage}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +self.connectionErrorCallBack(res); Review Comment: Done > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711315#comment-17711315 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163986037 ## wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js: ## @@ -117,8 +135,14 @@ this.iframe = null; if (progressPercent === '100') { - Wicket.$(this.statusid).setAttribute('hidden', ''); - Wicket.$(this.barid).setAttribute('hidden', ''); + var $statusId = Wicket.$(this.statusid); + if ($statusId != null) { + $statusId.setAttribute('hidden', ''); Review Comment: Done > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711307#comment-17711307 ] ASF subversion and git services commented on WICKET-7033: - Commit 32eb57e6afc03ae7258f902cd518c925b6307a58 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=32eb57e6af ] [WICKET-7033] clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711305#comment-17711305 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163964442 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. Review Comment: Done > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711240#comment-17711240 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163746668 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadResourceReference.java: ## @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.util.List; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.resource.IResource; +import org.apache.wicket.request.resource.ResourceReference; +import org.apache.wicket.util.lang.Bytes; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONException; +import com.github.openjson.JSONObject; + +/** + * A resource reference that provides default implementation of AbstractFileUploadResource. + * The implementation generates JSON response with data from the upload (this data is + * re-routed to page for things like getting the client file name and file size). + */ +public class FileUploadResourceReference extends ResourceReference +{ + + private final IUploadsFileManager uploadFileManager; + + private static FileUploadResourceReference i; Review Comment: Done ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711239#comment-17711239 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163742483 ## wicket-examples/src/main/java/org/apache/wicket/examples/upload/UploadToResourcePage.html: ## @@ -0,0 +1,39 @@ +http://wicket.apache.org;> + +Wicket Examples - upload + + legend { border: 1px solid #e9601a; background-color: #bbb; color: #fff; padding: 4px;} + fieldset { border: 1px solid #e9601a; padding: 10px; margin-top: 10px;} + + + + + + Wicket can upload to a mounted to a resource. Review Comment: Done > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711228#comment-17711228 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163719410 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/AbstractFileUploadResource.java: ## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.wicket.WicketRuntimeException; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.util.lang.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.openjson.JSONObject; + +/** + * The resource that handles the file uploads. + * Reads the file items from the request parameters and uses {@link IUploadsFileManager} + * to store them. + * Additionally, cares about the response's content type and body. + * + * This code was adapted from + * + * https://github.com/martin-g/blogs/blob/master/file-upload/src/main/java/com/mycompany/fileupload/AbstractFileUploadResource.java;>AbstractFileUploadResource.java + * + * The main difference is that there some JQuery plugin is used at client side (and it supports multiple uploads + + * some UI allowing to delete/preview files and so on). + * Here we are just using plain jQuery code at client side to upload a single file. + */ +public abstract class AbstractFileUploadResource extends AbstractResource +{ + private static final Logger LOG = LoggerFactory.getLogger(AbstractFileUploadResource.class); + + public static final String PARAM_NAME = "FILE-UPLOAD"; + + private final IUploadsFileManager fileManager; + + public AbstractFileUploadResource(IUploadsFileManager fileManager) + { + this.fileManager = fileManager; + } + + /** +* Reads and stores the uploaded files +* +* @param attributes +*Attributes +* @return ResourceResponse +*/ + @Override + protected ResourceResponse newResourceResponse(Attributes attributes) + { + final ResourceResponse resourceResponse = new ResourceResponse(); + + final ServletWebRequest webRequest = (ServletWebRequest) attributes.getRequest(); + + String identifier = webRequest.getRequestParameters().getParameterValue("uploadId").toString("resource"); + + try + { + MultipartServletWebRequest multiPartRequest = webRequest.newMultipartWebRequest(getMaxSize(), identifier); + multiPartRequest.parseFileParts(); + + RequestCycle.get().setRequest(multiPartRequest); + + Map> files = multiPartRequest.getFiles(); + List fileItems = files.get(PARAM_NAME); + + if (fileItems != null) + { + List fileUploads = new ArrayList<>(); + for (FileItem fileItem : fileItems) + { + fileUploads.add(new FileUpload(fileItem)); + } + saveFiles(fileUploads, identifier); + prepareResponse(resourceResponse, webRequest, fileUploads); + } + else + { +
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711227#comment-17711227 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163716664 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/AbstractFileUploadResource.java: ## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.wicket.WicketRuntimeException; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.util.lang.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.openjson.JSONObject; + +/** + * The resource that handles the file uploads. + * Reads the file items from the request parameters and uses {@link IUploadsFileManager} + * to store them. + * Additionally, cares about the response's content type and body. + * + * This code was adapted from + * + * https://github.com/martin-g/blogs/blob/master/file-upload/src/main/java/com/mycompany/fileupload/AbstractFileUploadResource.java;>AbstractFileUploadResource.java + * + * The main difference is that there some JQuery plugin is used at client side (and it supports multiple uploads + + * some UI allowing to delete/preview files and so on). + * Here we are just using plain jQuery code at client side to upload a single file. + */ +public abstract class AbstractFileUploadResource extends AbstractResource +{ + private static final Logger LOG = LoggerFactory.getLogger(AbstractFileUploadResource.class); + + public static final String PARAM_NAME = "FILE-UPLOAD"; + + private final IUploadsFileManager fileManager; + + public AbstractFileUploadResource(IUploadsFileManager fileManager) + { + this.fileManager = fileManager; + } + + /** +* Reads and stores the uploaded files +* +* @param attributes +*Attributes +* @return ResourceResponse +*/ + @Override + protected ResourceResponse newResourceResponse(Attributes attributes) + { + final ResourceResponse resourceResponse = new ResourceResponse(); + + final ServletWebRequest webRequest = (ServletWebRequest) attributes.getRequest(); + + String identifier = webRequest.getRequestParameters().getParameterValue("uploadId").toString("resource"); Review Comment: Done ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/AbstractFileUploadResource.java: ## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711191#comment-17711191 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163584820 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.js: ## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +;(function (undefined) { + +'use strict'; + +if (typeof(Wicket.FileUploadToResourceField) === 'object') { +return; +} + +Wicket.FileUploadToResourceField = function (settings, clientSideSuccessCallBack, clientSideCancelCallBack, connectionErrorCallBack) +{ +this.inputName = settings.inputName; +this.input = document.getElementById(this.inputName); +this.resourceUrl = settings.resourceUrl + "?uploadId=" + this.inputName; +this.ajaxCallBackUrl = settings.ajaxCallBackUrl; +this.clientSideSuccessCallBack = clientSideSuccessCallBack; +this.clientSideCancelCallBack = clientSideCancelCallBack; +this.connectionErrorCallBack = connectionErrorCallBack; +} + +Wicket.FileUploadToResourceField.prototype.upload = function() +{ +// we add the files to a FormData object. +var formData = new FormData(); +var totalfiles = this.input.files.length; +for (var index = 0; index < totalfiles; index++) { +formData.append("FILE-UPLOAD",this.input.files[index]); +} +// pass the input name to knw where to store files at server side. +formData.append("uploadId", this.inputName); +var self = this; +// we use jQuery to post the file to the resource (this.resourceUrl) +// and we keep a reference to the request in order to be able +// to cancel the upload +this.xhr = $.ajax({ +url: this.resourceUrl, +type: "POST", +data: formData, +processData: false, +contentType: false, +success: function (res) { +// do clean up on success +self.clientSideSuccessCallBack(); +if (res.error) { +var ep = {'success': false, 'errorMessage': res.errorMessage}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +self.connectionErrorCallBack(res); +} else { +var ep = {'success': true, 'filesInfo': JSON.stringify(res)}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +} +}, +error: function (jqXHR, textStatus, errorThrown) { +if (textStatus === "abort") { +// user aborted the upload. +self.clientSideCancelCallBack(); +var ep = {'success': false, 'errorMessage': 'upload.canceled'}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +} else if (textStatus === "error"){ +var ep = {'success': false, 'errorMessage': errorThrown}; +Wicket.Ajax.get({"u": self.ajaxCallBackUrl, "ep": ep}); +self.connectionErrorCallBack(); +} else if (textStatus === "parsererror"){ +// this error will only happen is generated JSON at server side is faulty +var data = jqXHR.responseText; +Wicket.Log.log(data); +} +} +}); +} + +// cancel the upload +Wicket.FileUploadToResourceField.prototype.cancel = function () { +// we have a reference to the request we can cancel it. +if (this.xhr) { +this.xhr.abort(); +Wicket.Log.log("upload canceled!"); Review Comment: Done > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 >
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711189#comment-17711189 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163581471 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711091#comment-17711091 ] ASF GitHub Bot commented on WICKET-7033: martin-g commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163223467 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711089#comment-17711089 ] ASF GitHub Bot commented on WICKET-7033: martin-g commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163222718 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17711088#comment-17711088 ] ASF GitHub Bot commented on WICKET-7033: martin-g commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1163221090 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadResourceReference.java: ## @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.util.List; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.resource.IResource; +import org.apache.wicket.request.resource.ResourceReference; +import org.apache.wicket.util.lang.Bytes; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONException; +import com.github.openjson.JSONObject; + +/** + * A resource reference that provides default implementation of AbstractFileUploadResource. + * The implementation generates JSON response with data from the upload (this data is + * re-routed to page for things like getting the client file name and file size). + */ +public class FileUploadResourceReference extends ResourceReference +{ + + private final IUploadsFileManager uploadFileManager; + + private static FileUploadResourceReference i; + + /** +* This method assumes {@link #createNewInstance(IUploadsFileManager, Bytes)} was called before Review Comment: You are right! > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710965#comment-17710965 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on PR #571: URL: https://github.com/apache/wicket/pull/571#issuecomment-1503391987 @martin-g Many thanks for all your comments. Addressing them ASAP > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710963#comment-17710963 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1162846986 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710962#comment-17710962 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1162843670 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710961#comment-17710961 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1162839484 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.java: ## @@ -0,0 +1,414 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import org.apache.commons.io.IOUtils; +import org.apache.wicket.Session; +import org.apache.wicket.ajax.AbstractDefaultAjaxBehavior; +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.AjaxUtils; +import org.apache.wicket.core.request.handler.IPartialPageRequestHandler; +import org.apache.wicket.markup.head.IHeaderResponse; +import org.apache.wicket.markup.head.JavaScriptHeaderItem; +import org.apache.wicket.markup.head.OnDomReadyHeaderItem; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.markup.html.form.upload.FileUploadField; +import org.apache.wicket.model.IModel; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.mapper.parameter.PageParameters; +import org.apache.wicket.request.resource.JavaScriptResourceReference; +import org.apache.wicket.resource.CoreLibrariesContributor; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONObject; + +/** + * Implementation of FileUploadField capable to uploading a file into a wicket mounted resource. + * This field does not require a {@link org.apache.wicket.markup.html.form.Form}, and field by itself + * does to upload of the file via the {@link #startUpload(IPartialPageRequestHandler)} method. See wicket examples. + */ +public abstract class FileUploadToResourceField extends FileUploadField +{ + +/** + * Info regarding an upload. + */ +public static final class UploadInfo +{ +private File file; +private final String clientFileName; + +private final long size; + +private final String contentType; + +public UploadInfo(String clientFileName, long size, String contentType) +{ +this.clientFileName = clientFileName; +this.size = size; +this.contentType = contentType; +} + +public File getFile() +{ +return file; +} + +public void setFile(File file) +{ +this.file = file; +} + +public String getClientFileName() +{ +return clientFileName; +} + +public long getSize() +{ +return size; +} + +public String getContentType() +{ +return contentType; +} + +@Override +public boolean equals(Object o) +{ +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +UploadInfo fileInfo = (UploadInfo) o; +return Objects.equals(clientFileName, fileInfo.clientFileName); +} + +/** + * @return the bytes associated with the upload. + */ +public byte[] get() +{ +byte[] fileData = new byte[(int) getSize()]; +InputStream fis = null; + +try +{ +fis = new FileInputStream(file); +IOUtils.readFully(fis, fileData); +} +catch (IOException e) +{ +fileData = null; +} +finally +{ +IOUtils.closeQuietly(fis); +} + +return fileData; +} + +@Override +public int hashCode() +{ +return Objects.hash(clientFileName); +} + +public static List
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710958#comment-17710958 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1162830954 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadResourceReference.java: ## @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.util.List; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.resource.IResource; +import org.apache.wicket.request.resource.ResourceReference; +import org.apache.wicket.util.lang.Bytes; +import com.github.openjson.JSONArray; +import com.github.openjson.JSONException; +import com.github.openjson.JSONObject; + +/** + * A resource reference that provides default implementation of AbstractFileUploadResource. + * The implementation generates JSON response with data from the upload (this data is + * re-routed to page for things like getting the client file name and file size). + */ +public class FileUploadResourceReference extends ResourceReference +{ + + private final IUploadsFileManager uploadFileManager; + + private static FileUploadResourceReference i; + + /** +* This method assumes {@link #createNewInstance(IUploadsFileManager, Bytes)} was called before Review Comment: Not following you. Then you will need to pass arguments > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710957#comment-17710957 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1162828473 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/AbstractFileUploadResource.java: ## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.wicket.WicketRuntimeException; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.util.lang.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.openjson.JSONObject; + +/** + * The resource that handles the file uploads. + * Reads the file items from the request parameters and uses {@link IUploadsFileManager} + * to store them. + * Additionally, cares about the response's content type and body. + * + * This code was adapted from + * + * https://github.com/martin-g/blogs/blob/master/file-upload/src/main/java/com/mycompany/fileupload/AbstractFileUploadResource.java;>AbstractFileUploadResource.java + * + * The main difference is that there some JQuery plugin is used at client side (and it supports multiple uploads + + * some UI allowing to delete/preview files and so on). + * Here we are just using plain jQuery code at client side to upload a single file. + */ +public abstract class AbstractFileUploadResource extends AbstractResource +{ + private static final Logger LOG = LoggerFactory.getLogger(AbstractFileUploadResource.class); + + public static final String PARAM_NAME = "FILE-UPLOAD"; + + private final IUploadsFileManager fileManager; + + public AbstractFileUploadResource(IUploadsFileManager fileManager) + { + this.fileManager = fileManager; + } + + /** +* Reads and stores the uploaded files +* +* @param attributes +*Attributes +* @return ResourceResponse +*/ + @Override + protected ResourceResponse newResourceResponse(Attributes attributes) + { + final ResourceResponse resourceResponse = new ResourceResponse(); + + final ServletWebRequest webRequest = (ServletWebRequest) attributes.getRequest(); + + String identifier = webRequest.getRequestParameters().getParameterValue("uploadId").toString("resource"); + + try + { + MultipartServletWebRequest multiPartRequest = webRequest.newMultipartWebRequest(getMaxSize(), identifier); + multiPartRequest.parseFileParts(); + + RequestCycle.get().setRequest(multiPartRequest); + + Map> files = multiPartRequest.getFiles(); + List fileItems = files.get(PARAM_NAME); + + if (fileItems != null) + { + List fileUploads = new ArrayList<>(); + for (FileItem fileItem : fileItems) + { + fileUploads.add(new FileUpload(fileItem)); + } + saveFiles(fileUploads, identifier); + prepareResponse(resourceResponse, webRequest, fileUploads); + } + else + { +
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710955#comment-17710955 ] ASF GitHub Bot commented on WICKET-7033: reiern70 commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1162824718 ## wicket-extensions/src/main/java/org/apache/wicket/extensions/ajax/markup/html/form/upload/progressbar.js: ## @@ -117,8 +135,14 @@ this.iframe = null; if (progressPercent === '100') { - Wicket.$(this.statusid).setAttribute('hidden', ''); - Wicket.$(this.barid).setAttribute('hidden', ''); + var $statusId = Wicket.$(this.statusid); + if ($statusId != null) { + $statusId.setAttribute('hidden', ''); Review Comment: Maybe. I need to check. I just modified this because we had some client side errors in some conner cases in our app. > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710919#comment-17710919 ] ASF GitHub Bot commented on WICKET-7033: martin-g commented on code in PR #571: URL: https://github.com/apache/wicket/pull/571#discussion_r1162678493 ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/AbstractFileUploadResource.java: ## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.wicket.WicketRuntimeException; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.util.lang.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.openjson.JSONObject; + +/** + * The resource that handles the file uploads. + * Reads the file items from the request parameters and uses {@link IUploadsFileManager} Review Comment: s/IUploadsFileManager/IFileUploadManager/ ? ## wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/AbstractFileUploadResource.java: ## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.wicket.markup.html.form.upload.resource; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileUploadBase; +import org.apache.commons.fileupload.FileUploadException; +import org.apache.wicket.WicketRuntimeException; +import org.apache.wicket.markup.html.form.upload.FileUpload; +import org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest; +import org.apache.wicket.protocol.http.servlet.ServletWebRequest; +import org.apache.wicket.request.cycle.RequestCycle; +import org.apache.wicket.request.resource.AbstractResource; +import org.apache.wicket.util.lang.Bytes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.github.openjson.JSONObject; + +/** + * The resource that handles the file uploads. + * Reads the file items from the request parameters and uses {@link IUploadsFileManager} + * to store them. + * Additionally, cares about the response's content type and body. + * + * This code was adapted from + * + * https://github.com/martin-g/blogs/blob/master/file-upload/src/main/java/com/mycompany/fileupload/AbstractFileUploadResource.java;>AbstractFileUploadResource.java + * + * The main difference is that there some JQuery plugin is used at client side (and it supports multiple uploads + + * some UI allowing to delete/preview files and so on). + * Here we are just using plain jQuery code at client side to upload a single file. + */ +public abstract class AbstractFileUploadResource extends AbstractResource +{ + private static
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710876#comment-17710876 ] ASF subversion and git services commented on WICKET-7033: - Commit 0385f7da95d47c8ee3063781199f8204ebc1e53d in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=0385f7da95 ] [WICKET-7033] implementation of uploading files into to a mounted resource + adapting upload progress bar to work in such use case > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710797#comment-17710797 ] ASF subversion and git services commented on WICKET-7033: - Commit 4f3b10137cd0d20be0c7531faaa21378c04776d0 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=4f3b10137c ] [WICKET-7033] add support for several files. > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710430#comment-17710430 ] ASF subversion and git services commented on WICKET-7033: - Commit 4e891340554ea77ed93569473b08de4cdb7671e6 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=4e89134055 ] [WICKET-7033] minor clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710429#comment-17710429 ] ASF subversion and git services commented on WICKET-7033: - Commit 443cddf9e91d92c830dffa894ed567ca1b47d334 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=443cddf9e9 ] [WICKET-7033] minor clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710076#comment-17710076 ] ASF subversion and git services commented on WICKET-7033: - Commit 8dab6d080a4832f836f16f70def545aff57a0e5a in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=8dab6d080a ] [WICKET-7033] add content type and size > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17710067#comment-17710067 ] ASF subversion and git services commented on WICKET-7033: - Commit 31070dd1bf9235048cb2a2b562ae63c84aae10e9 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=31070dd1bf ] [WICKET-7033] clean up > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17709836#comment-17709836 ] ASF subversion and git services commented on WICKET-7033: - Commit b3df5eeef435c165f02d44f461f626ebb219f21c in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=b3df5eeef4 ] [WICKET-7033] prototype implementation of uploading file to a resource > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17709835#comment-17709835 ] ASF subversion and git services commented on WICKET-7033: - Commit 9dcdc8cceadacf3ff155462b9bf433f6b009bf86 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=9dcdc8ccea ] [WICKET-7033] WIP > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17709834#comment-17709834 ] ASF subversion and git services commented on WICKET-7033: - Commit ccb31a5bf3d35d79e4ae0a45e353fee0cd106676 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=ccb31a5bf3 ] [WICKET-7033] WIP > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17709831#comment-17709831 ] ASF subversion and git services commented on WICKET-7033: - Commit ff30454860197adc4594b775854f0e0deaa62b1f in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=ff30454860 ] [WICKET-7033] WIP > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17709660#comment-17709660 ] ASF subversion and git services commented on WICKET-7033: - Commit 351802069ea1a10f4521ebc8cdf22901e674eebc in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=351802069e ] [WICKET-7033] WIP > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17709658#comment-17709658 ] ASF subversion and git services commented on WICKET-7033: - Commit 9d162710af31c6eb2610d54c886b1d4075f5075e in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=9d162710af ] [WICKET-7033] WIP > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17709647#comment-17709647 ] ASF subversion and git services commented on WICKET-7033: - Commit aab23d5752cc69839918be28c7e4330132a6538f in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=aab23d5752 ] [WICKET-7033] WIP > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (WICKET-7033) add support to uploading to a resource
[ https://issues.apache.org/jira/browse/WICKET-7033?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17709648#comment-17709648 ] ASF subversion and git services commented on WICKET-7033: - Commit 04c838f0d74b2907183cfdc16ae9ff38dba5d265 in wicket's branch refs/heads/reiern70/WICKET-7033 from reiern70 [ https://gitbox.apache.org/repos/asf?p=wicket.git;h=04c838f0d7 ] [WICKET-7033] WIP > add support to uploading to a resource > -- > > Key: WICKET-7033 > URL: https://issues.apache.org/jira/browse/WICKET-7033 > Project: Wicket > Issue Type: New Feature > Components: wicket >Reporter: Ernesto Reinaldo Barreiro >Assignee: Ernesto Reinaldo Barreiro >Priority: Major > Fix For: 10.0.0, 9.14.0 > > > Add support for the following: > * Upload to a resource in an asynchronous non page blocking request > * Add an optional way to block the user from leaving the page while the > upload is happening > * Ways to cancel the upload > * Adapt the upload progress bar to work with this new "component" and improve > its code as in some corner cases it is producing client side errors (I > created an issue for that some time ago). > * Maybe useful too: create a web socket based progress bar, as the upload > progress bar now works pulling the server every second. > * Also to add an example to wicket-examples that uses a smart JS uploader, > like in the blog > (https://github.com/martin-g/blogs/blob/master/file-upload/). This way you > will verify that the new APIs are easily extendable. -- This message was sent by Atlassian Jira (v8.20.10#820010)