This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
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 Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom sizeErrorLabel with maxRequestSize?" Watch "Custom sizeErrorLabel with maxRequestSize?" New topic

Custom sizeErrorLabel with maxRequestSize?

pasquale vitale

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?


Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16476

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

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

rocket mass heater kickstarter
subject: Custom sizeErrorLabel with maxRequestSize?