• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

inputFileUpload - uploadMaxFileSize

 
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.

I'm trying to use the inputFileUpload component from Tomahawk, but getting some problem when a file that is greater than defined by parameter uploadMaxFileSize.
When it's happening, the Tomahawk ExtensionsFilter only prints out the stack error on console:
"SizeLimitExceededException while uploading file."

And when this occurs, JSF goes from RESTORE_VIEW phase to RENDER_RESPONSE phase.

So I have no chance to handle this problem or even deal with this situation...

I don't want to use richfaces/primefaces/icefaces on my project. I'm limited to use JSF and Tomahawk only.
I already was trying to create my own component but I have no time to continue this subproject.

Does anybody here already had this problem?

Thanks!


 
Adolfo Eloy
Ranch Hand
Posts: 146
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Researching about this topic, I found that there is no way when using Tomahawk FileUpload Component.

So, the only way to have a component similar to FileUpload from Tomahawk, were creating a custom JSF component to what I need.

Thanks.
 
Saloon Keeper
Posts: 22483
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you can intercept the Exception and handle it with a custom Error Page in web.xml?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously a very late reply, but since I was wondering what to do with this problem, I will put forward the solution that worked for me.

When in doubt, cheat.

Since the lifecycle is your problem because of the value in the web.xml, set it larger, to some obscene number if you really like, I used 10m.

This should allow any reasonalbe (but over) attempt to load an image to progress to your business logic.

Once there, inside your try/catch after you have checked for nulls etc, throw in a simple if statement that checks that the "file".getSize() is < your max value, if it isnt then "throw new SizeLimitExceededException("File to large", yourFileSize, maxSize)" and then catch that exception and deal with it how you wish, i logged it and sent them to an error page.

Of course if you arent interested in logging that exception you could probably just return "failure" and redirect to your error page without having thrown a new exception.
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic