• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 2: fileupload configuration

 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Instead of configuring the file upload options declaratively, how do I do it programmatically?


<interceptor-ref name="fileUpload">
<param name="maximumSize">
1024
</param>
<param name="allowedTypes">
image/png,image/gif,image/jpeg
</param>
</interceptor-ref>



The FileUploadInterceptor provides 2 methods: setAllowedTypes and setMaximumSize. How could I invoke these methods? I would want to read these values from a database table then call the methods to configure.

Cheers!
 
Author
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should check out the Spring integration. You can have spring manage the creation of your interceptor objects. That would greatly increase your options for setting those setters.
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by chad michael davis:
You should check out the Spring integration. You can have spring manage the creation of your interceptor objects. That would greatly increase your options for setting those setters.



If I opt not to use Spring integration, is there any other way to do it programmatically?

Thanks!
 
author
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd recommend subclassing the interceptor in question, and calling those setters in the constructor. Then, use that interceptor whenever you'd use the old fileupload interceptor. You may have to create your own interceptor stack that contains your new interceptor and not the old one.
 
Chengwei Lee
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Don Brown:
I'd recommend subclassing the interceptor in question, and calling those setters in the constructor. Then, use that interceptor whenever you'd use the old fileupload interceptor. You may have to create your own interceptor stack that contains your new interceptor and not the old one.



This would be a simpler approach. I'm just puzzled that Struts 2 does not provide this feature both declaratively and programmatically out of the box. Thanks!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic