PrimeFaces p:fileUpload not Appearing

I hit this issue with the PrimeFaces p:fileUpload component this morning and it had me going for about an hour until I figured out what was wrong. A good googling shows that more than a few people have hit this problem but no one had reported a solution, there was even a bug report closed as can’t reproduce.

So what are the symptoms…

You place a p:fileUpload component on the page expecting it to appear in the final rendered result and, well, nothing appears. There’s no upload button nothing. You wrap the “foo” and “bar” around the component and they appear fine but with nothing appearing between them. You look at the page source and guess what, you see HTML for the component.

Well, it turns out that if you have specified the value of the allowTypes attribute incorrectly (I had “*.xls;*.xslx”) the component just fails silently. This was particularly annoying because that value worked in version 3.1 and stopped working in 3.3. I’d upgraded a good while ago and somehow had missed this particular failure.

It’s probably worth stating that this component is likely to fail if any of the other attributes are incorrectly specified as well. As always with PrimeFaces remember that the library is a necessary evil, not your friend.

Posted in Java EE and tagged , , .

Leave a Reply

Your email address will not be published. Required fields are marked *