I would like to know if there is a method to label and rename the text displayed by JSF Choose a File
when I'm using the tag <h:InputFile>
in JSF.
相关问题
- java.lang.NullPointerException at java.io.PrintWri
- h:selectOneMenu in p:dataTable doesn't submit
- Upload file to Google Cloud Storage using AngularJ
- PrimeFaces block UI does not work when the compone
- primefaces orderlist not getting updated with the
相关文章
- File Upload of more than 4GB
- The current request is not a multipart request - S
- Input file in laravel 5.2?
- How to allow numbers only using f:validateRegex
- JSF 2.0: ajax request when press ENTER
- Formatting a double in JSF
- Xcode doesn't recognize NSLabel
- Why does my form not upload files in Internet Expl
That's not possible with native HTML. The appearance and the button's label is browser-dependent. The particular "Choose File" label is recognizable as the one from Chrome with English language pack (e.g. FireFox uses "Browse..."). As JSF is in the context of this question just a HTML code generator, it can't do much for you either.
There are several ways to achieve this. All can be found in this HTML+CSS targeted Q&A: Styling an input type="file" button, particularly this answer.
Easiest way is to reference it via
<h:outputLabel for>
, style it to look like a button and hide the actual file upload component. Clicking the label element will as usual just delegate the click event to the associated input element. See also Purpose of the h:outputLabel and its "for" attribute.Here's a non-IE compatible kickoff example (it's supported in IE's successor Edge):
If you'd like to support IE9+ too, replace
appearance: button
by abackground
andborder
. It's only harder to get it to look like a true button. The below is far from ideal, but should at least get you started.If you'd like to support IE6-8 too, which won't delegate the label's click event to the hidden input element, then well, head to the aforementioned related question for CSS tricks on that and rewrite JSF code in such way that it generates exactly the desired HTML+CSS(+JS) output.
A completely different alternative is to grab an UI oriented JSF component library, such as PrimeFaces which is based on jQuery UI. See also its
<p:fileUpload>
showcase.