Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

inputFileUpload - uploadMaxFileSize  RSS feed

 
Adolfo Eloy
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.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE 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?
 
Simple Simon
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!