permaculture playing cards
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
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: 17417

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.

An IDE is no substitute for an Intelligent Developer.
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

I agree. Here's the link:
subject: Custom sizeErrorLabel with maxRequestSize?
jQuery in Action, 3rd edition