Re: Is there any way to get an error message when uploading a file that exceeds the size limit?
https://github.com/try0/wicket-fileupload-example/blob/main/wicket-fileupload-example-app/src/main/java/jp/try0/wicket/example/fileupload/HomePage.java#L52 if this line uncomment, FilesSelectedBehavior#onSelected is not fired. 2022年6月10日(金) 23:18 Ryo Tsunoda : > >Hum... if you can explain more I would appreciate it... because maybe > this can be improved in Wicket itself. > > If use FileUploadField#setRequired(true), FormComponent #validateRequired > -> #checkRequired will be executed. > But FileUploadField#getInput() returns null, so validation result in an > error. > Therefore, It seems that the Behavior's(FilesSelectedBehavior) event that > FileUploadField has is not fired. > > 2022年6月10日(金) 21:19 Ernesto Reinaldo Barreiro : > >> Hi, >> >> On Fri, Jun 10, 2022 at 2:31 PM Ryo Tsunoda >> wrote: >> >> > Thanks for the reply. >> > >> > I have tried it and I can display the error without changing the request >> > limit. >> > Thank you. >> > >> >> Yes. This is just a kind of preprocessing. When the file (files) is (are) >> selected the info is collected via JavaScript and is sent to the server. >> Thus you can decide what to do before uploading: e.g an upload button >> might >> only be enabled if file (files) match your expectations regarding type, >> syze and so on. >> >> >> > It does not seem to work well when used with >> FileUploadField#setRequired. >> > I will change the implementation of the required validation and then use >> > that. >> > >> Hum... if you can explain more I would appreciate it... because maybe this >> can be improved in Wicket itself. >> >> >> >> > >> > 2022年6月10日(金) 16:21 Ernesto Reinaldo Barreiro : >> > >> > > See >> > > >> > > >> > > >> > >> https://javadoc.io/doc/org.apache.wicket/wicket-core/9.4.0/org/apache/wicket/markup/html/form/upload/FilesSelectedBehavior.html >> > > >> > > This behavior can be used to get an AJAX round trip to the server when >> > the >> > > user selects a file (or files). Then you can use that information to >> let >> > > the user know the selected file is bigger than it should (and possibly >> > > disable the upload "button"). >> > > >> > > >> > > On Thu, Jun 9, 2022 at 2:57 PM Ryo Tsunoda < >> try0.developm...@gmail.com> >> > > wrote: >> > > >> > > > Hi. >> > > > >> > > > Looking at Form#onFileUploadException, I see that it sets an error >> > > message >> > > > (resource key: uploadTooLarge), is there any way to display this >> error >> > in >> > > > the browser? >> > > > >> > > > I use Form#setMaxSize and >> > ApplicationSettings#setDefaultMaximumUploadSize >> > > > methods. >> > > > When I upload a file that exceeds these settings, I would like to >> > return >> > > a >> > > > response with an error message and display it on browser. However, >> the >> > > > browser displays [ERR_CONNECTION_RESET] now. >> > > > >> > > > >> > > > Regards, >> > > > Ryo Tsunoda. >> > > > >> > > >> > > >> > > -- >> > > Regards - Ernesto Reinaldo Barreiro >> > > >> > >> >> >> -- >> Regards - Ernesto Reinaldo Barreiro >> >
Re: Is there any way to get an error message when uploading a file that exceeds the size limit?
>Hum... if you can explain more I would appreciate it... because maybe this can be improved in Wicket itself. If use FileUploadField#setRequired(true), FormComponent #validateRequired -> #checkRequired will be executed. But FileUploadField#getInput() returns null, so validation result in an error. Therefore, It seems that the Behavior's(FilesSelectedBehavior) event that FileUploadField has is not fired. 2022年6月10日(金) 21:19 Ernesto Reinaldo Barreiro : > Hi, > > On Fri, Jun 10, 2022 at 2:31 PM Ryo Tsunoda > wrote: > > > Thanks for the reply. > > > > I have tried it and I can display the error without changing the request > > limit. > > Thank you. > > > > Yes. This is just a kind of preprocessing. When the file (files) is (are) > selected the info is collected via JavaScript and is sent to the server. > Thus you can decide what to do before uploading: e.g an upload button might > only be enabled if file (files) match your expectations regarding type, > syze and so on. > > > > It does not seem to work well when used with FileUploadField#setRequired. > > I will change the implementation of the required validation and then use > > that. > > > Hum... if you can explain more I would appreciate it... because maybe this > can be improved in Wicket itself. > > > > > > > 2022年6月10日(金) 16:21 Ernesto Reinaldo Barreiro : > > > > > See > > > > > > > > > > > > https://javadoc.io/doc/org.apache.wicket/wicket-core/9.4.0/org/apache/wicket/markup/html/form/upload/FilesSelectedBehavior.html > > > > > > This behavior can be used to get an AJAX round trip to the server when > > the > > > user selects a file (or files). Then you can use that information to > let > > > the user know the selected file is bigger than it should (and possibly > > > disable the upload "button"). > > > > > > > > > On Thu, Jun 9, 2022 at 2:57 PM Ryo Tsunoda > > > > wrote: > > > > > > > Hi. > > > > > > > > Looking at Form#onFileUploadException, I see that it sets an error > > > message > > > > (resource key: uploadTooLarge), is there any way to display this > error > > in > > > > the browser? > > > > > > > > I use Form#setMaxSize and > > ApplicationSettings#setDefaultMaximumUploadSize > > > > methods. > > > > When I upload a file that exceeds these settings, I would like to > > return > > > a > > > > response with an error message and display it on browser. However, > the > > > > browser displays [ERR_CONNECTION_RESET] now. > > > > > > > > > > > > Regards, > > > > Ryo Tsunoda. > > > > > > > > > > > > > -- > > > Regards - Ernesto Reinaldo Barreiro > > > > > > > > -- > Regards - Ernesto Reinaldo Barreiro >
Re: Is there any way to get an error message when uploading a file that exceeds the size limit?
Hi, On Fri, Jun 10, 2022 at 2:31 PM Ryo Tsunoda wrote: > Thanks for the reply. > > I have tried it and I can display the error without changing the request > limit. > Thank you. > Yes. This is just a kind of preprocessing. When the file (files) is (are) selected the info is collected via JavaScript and is sent to the server. Thus you can decide what to do before uploading: e.g an upload button might only be enabled if file (files) match your expectations regarding type, syze and so on. > It does not seem to work well when used with FileUploadField#setRequired. > I will change the implementation of the required validation and then use > that. > Hum... if you can explain more I would appreciate it... because maybe this can be improved in Wicket itself. > > 2022年6月10日(金) 16:21 Ernesto Reinaldo Barreiro : > > > See > > > > > > > https://javadoc.io/doc/org.apache.wicket/wicket-core/9.4.0/org/apache/wicket/markup/html/form/upload/FilesSelectedBehavior.html > > > > This behavior can be used to get an AJAX round trip to the server when > the > > user selects a file (or files). Then you can use that information to let > > the user know the selected file is bigger than it should (and possibly > > disable the upload "button"). > > > > > > On Thu, Jun 9, 2022 at 2:57 PM Ryo Tsunoda > > wrote: > > > > > Hi. > > > > > > Looking at Form#onFileUploadException, I see that it sets an error > > message > > > (resource key: uploadTooLarge), is there any way to display this error > in > > > the browser? > > > > > > I use Form#setMaxSize and > ApplicationSettings#setDefaultMaximumUploadSize > > > methods. > > > When I upload a file that exceeds these settings, I would like to > return > > a > > > response with an error message and display it on browser. However, the > > > browser displays [ERR_CONNECTION_RESET] now. > > > > > > > > > Regards, > > > Ryo Tsunoda. > > > > > > > > > -- > > Regards - Ernesto Reinaldo Barreiro > > > -- Regards - Ernesto Reinaldo Barreiro
Re: Is there any way to get an error message when uploading a file that exceeds the size limit?
Thanks for the reply. I have tried it and I can display the error without changing the request limit. Thank you. It does not seem to work well when used with FileUploadField#setRequired. I will change the implementation of the required validation and then use that. 2022年6月10日(金) 16:21 Ernesto Reinaldo Barreiro : > See > > > https://javadoc.io/doc/org.apache.wicket/wicket-core/9.4.0/org/apache/wicket/markup/html/form/upload/FilesSelectedBehavior.html > > This behavior can be used to get an AJAX round trip to the server when the > user selects a file (or files). Then you can use that information to let > the user know the selected file is bigger than it should (and possibly > disable the upload "button"). > > > On Thu, Jun 9, 2022 at 2:57 PM Ryo Tsunoda > wrote: > > > Hi. > > > > Looking at Form#onFileUploadException, I see that it sets an error > message > > (resource key: uploadTooLarge), is there any way to display this error in > > the browser? > > > > I use Form#setMaxSize and ApplicationSettings#setDefaultMaximumUploadSize > > methods. > > When I upload a file that exceeds these settings, I would like to return > a > > response with an error message and display it on browser. However, the > > browser displays [ERR_CONNECTION_RESET] now. > > > > > > Regards, > > Ryo Tsunoda. > > > > > -- > Regards - Ernesto Reinaldo Barreiro >
Re: Is there any way to get an error message when uploading a file that exceeds the size limit?
See https://javadoc.io/doc/org.apache.wicket/wicket-core/9.4.0/org/apache/wicket/markup/html/form/upload/FilesSelectedBehavior.html This behavior can be used to get an AJAX round trip to the server when the user selects a file (or files). Then you can use that information to let the user know the selected file is bigger than it should (and possibly disable the upload "button"). On Thu, Jun 9, 2022 at 2:57 PM Ryo Tsunoda wrote: > Hi. > > Looking at Form#onFileUploadException, I see that it sets an error message > (resource key: uploadTooLarge), is there any way to display this error in > the browser? > > I use Form#setMaxSize and ApplicationSettings#setDefaultMaximumUploadSize > methods. > When I upload a file that exceeds these settings, I would like to return a > response with an error message and display it on browser. However, the > browser displays [ERR_CONNECTION_RESET] now. > > > Regards, > Ryo Tsunoda. > -- Regards - Ernesto Reinaldo Barreiro