Change default button label of <p:fileUpload mode="simple">
Asked Answered
J

3

10

I am using <p:fileUpload mode="simple">. The button label shows differently in Chrome and Firefox. I would like it to be the same across browsers. I tried changing it by setting the label attribute as follows:

<p:fileUpload label="Browse" ... mode="simple" />

However, it had no effect. How can I achieve this?

Jedthus answered 4/7, 2013 at 12:4 Comment(0)
P
14

That's not possible in current PrimeFaces 3.x version. It's only possible when you use mode="advanced" instead of mode="simple".

As to your attempt to use the label attribute, this attribute is only used as label in validation error messages associated with the input component. With your label="Browse" attempt, in case of a required="true" validation error, the message would appear like so "Browse is required" instead of "formId:inputId is required".


Update: since PrimeFaces 5.x, you can add skinSimple="true" to give mode="simple" the desired skin/look'n'feel as the remainder. Also, the label will actually be used as button label. See also the showcase.

<p:fileUpload label="Browse" ... mode="simple" skinSimple="true" />
Passmore answered 4/7, 2013 at 15:41 Comment(0)
H
8

I'm using PrimeFaces 5.0, and it's possible change the default names in advanced mode: Choose - Upload - Cancel You can use: label="" uploadLabel="" cancelLabel="" to set your custom names.

The implementation is here: http://www.primefaces.org/showcase/ui/file/upload/single.xhtml

Hadwin answered 30/5, 2014 at 13:28 Comment(0)
D
0

Look at this answer https://stackoverflow.com/a/18909078. We run with a similar problem on our Web site and we plan looking closer at that Bootstrap filestyle plugin http://markusslima.github.io/bootstrap-filestyle/.

Ditchwater answered 11/12, 2013 at 1:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.