my dog learned polymorphism*
The moose likes JSF and the fly likes Custom sizeErrorLabel with maxRequestSize? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom sizeErrorLabel with maxRequestSize?" Watch "Custom sizeErrorLabel with maxRequestSize?" New topic
Author

Custom sizeErrorLabel with maxRequestSize?

pasquale vitale
Greenhorn

Joined: Aug 22, 2008
Posts: 10
Hi all,
I'm using rich:fileUpload component in my app.
To restrict file size for upload, I have setting into web.xml the maxRequestSize param in the filter tag. It's works.

When I use for upload a file with size greater than maxRequestSize param, it is display out "File size restricted".

Now I have a properties file with internalization and in my bean (that uses rich:fileUpload component) I use a resourceBundle to change all label in fileUpload component:

<rich:fileUpload ... sizeErrorLabel="#{resourceBundle.msgSizeLimited}" .... />

Can I modify this message (msgSizeLimited) using maxRequestSize param?
I wish to get: "Use file size smaller than 'maxRequestSize param'".
If it is possibile, how can I do it?

Also I can to use my bean to format sizeErrorLabel:
<rich:fileUpload ... sizeErrorLabel="#{bean.stringSizeLimited}" .... />
but I don't know how to read a maxRequestSize param into web.xml.

Finally, only for info, can I to use a label as "Use file size smaller than {0}", and to use a <f:param ... /> into rich:fileUpload component?


Thanks
Pasquy



Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950
    
  19

Getting the maxRequestSize might be a challenge, since as I read it, you'd have to locate the filter and ask the filter for the value it had been configured with. Assuming that it it was willing to tell you. Possibly you could wrap the filter class with one of your own to make it easier.

I don't think you can parameterize errorlabel attributes, so that lets that one out. If you get the message from a backing bean, you can have the property accessor format the message before returning it, however.

On the last one, you can probably specify "Use file size smaller than #{myBean.maxRequestSize}" on your label.


Customer surveys are for companies who didn't pay proper attention to begin with.
pasquale vitale
Greenhorn

Joined: Aug 22, 2008
Posts: 10
Thank Mill,
I have created a my filter (that extends org.ajax4jsf.Filter) and into init() method I read my maxRequestSize param and it put in session.
In my bean I get my maxRequestSize param from session.
It's works

bye
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom sizeErrorLabel with maxRequestSize?
 
Similar Threads
Problem Migrating a Project from Weblogic 9.2 to Tomcat 6.0.29
Excel number of rows limit for Richfaces <rich:fileUpload>
java.lang.IllegalStateException: using sendRedirect()
let's discuss to implementing multiple controllers by using struts1.0
local and web server