0

I'm using JSF 2.0 and need to allow users to upload images. I thought to use <t:inputFileUpload> and read it behaves similarly to <input type="file"> however I can never see a 'browse' option in any browser I use.

I have configured my web.xml properly and have <h:form enctype="multipart/form-data"> as my form beginning. There is also only one tag inside the form. I also have all necessary jars from what I can gather.

Anyone else experience this?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Open page in browser, rightclick and *View Source*. Is the `` tag been parsed? Or is it still unparsed there in the generated HTML output? – BalusC May 02 '12 at 03:42
  • I can see followed by input tags for the submit button. On inspect element you can see the attribute has been given dimensions "0px x 0px" – user997052 May 02 '12 at 19:47

1 Answers1

0

If you see the <t:inputFileUpload> unparsed in the generated HTML output instead of the <input type="file"> which it is supposed to generate, then it means that the t:xxx namespace is not registered, or that the JAR files containing it are not in the webapp's runtime classpath. This way JSF/Facelets will just treat it as plain text instead of a real JSF tag and it will end up unparsed in the HTML output. The webbrowser only understands HTML tags, so it will do nothing with the unparsed JSF tag and hence you see nothing in the webbrowser's UI presentation.

Make sure that the Tomahawk JAR files are all in /WEB-INF/lib folder of the webapp and make sure that you've declared the t:xxx namespace in the view as follows:

xmlns:t="http://myfaces.apache.org/tomahawk"
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • The first thing I checked was WEB-INF/lib folder and my xmlns declarations. Everything seems exact, ive never seen anything like this before. Deploying myfaces-examples from apache show it working correctly. Coying all the jars, included any others i need, from the working examples still doesn't parse the tag. – user997052 May 02 '12 at 20:41
  • Are you sure you're using the right JARs for Tomahawk? Tomahawk comes in "for JSF 1.2" and "for JSF 2.0" flavors. Are you sure that the XML namespace is been declared in the top level view where the Tomahawk file upload tag resides (and thus not only in some master template or so)? – BalusC May 02 '12 at 20:43
  • I've started a simple - single xhmtl page app - that has the latest Tomahawk 1.1.12 jars for JSF 2.0 (as defined in faces-config) and it's still not parsing the tag. No master template. – user997052 May 02 '12 at 20:57
  • I'm thinking it might be something to do with my servlet configuration not conforming to JSF 2.0 with MyFaces. I have seen that this can mean some tags aren't parsed properly. – user997052 May 02 '12 at 21:29
  • That would mean that **ALL** JSF tags are not parsed at all. Do you see `` or `
    ` in the HTML output? If you're seeing `` instead of ``, then it indeed means that your request URL didn't match the `FacesServlet`'s URL pattern. You'd need to make sure that the request URL (as you see in browser's address bar) matches the `` of the `FacesServlet` as configured in `web.xml`.
    – BalusC May 02 '12 at 21:29
  • Okay, well all other tags seem to be parsed correctly to plain html. So its not my servlet. My url-patterns are as expected as well – user997052 May 02 '12 at 21:38
  • Are you sure that the webapp's startup log is free of warnings and exceptions? Perhaps Tomahawk just failed to initialize on startup. – BalusC May 02 '12 at 21:48