File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes A pseudo file-uploader? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "A pseudo file-uploader?" Watch "A pseudo file-uploader?" New topic

A pseudo file-uploader?

Roberto Betancourt

Joined: Oct 23, 2009
Posts: 1
hello, I'm building a simple app with Icefaces and i need a file uploader that doesn't actually upload anything, i just need to get the string of the path that the client computer selects in the file explorer. I've already tried with the following code:

<ice:form id="contentForm">
<ice:panelGrid columns="1" id="panelGrid2">

<ice:inputFile id="input" binding="#{Calendario.input}" actionListener="#{Calendario.Link_processAction}"/>


and the actionListener for the upload button:

This always results in a null and the selected file gets "uploaded" in the netbeans project folder, which is a negative consequence for me.

Thanks for the help
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17410

The fileupload JSF control renders as an HTML <tinput type="file"> tag (or something close to that). The processing of this tag is done by the user's client application (web browser), and, by definition, when an HTML form is submitted with a multipart MIME type, the contents of the selected file are MIME-encoded and bundled into the data stream that the user's browser transmits to the server. Which means that you'd need a custom browser with "pseudo file upload" capabilities to make that work.

I'm not sure what benefit comes from telling the server the path of the client's file gives, anyway, since weeb servers aren't allowed to reach down and fetch client's files anyway.

And, BTW, Internet Explorer uploads the complete absolute pathname, but other browsers such as Firefox upload relative paths. I think that's actually an IE bug.

An IDE is no substitute for an Intelligent Developer.
Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203
You may want to add enctype="multipart/form-data" to your form tag. The standard h:form supports this attribute. Typical usage is as below:

You seem to be using ice faces. Check the documentation of ice:form tag.

Cheers.<br />Keerthi<br />(SCJP, SCWCD, SCBCD)
I agree. Here's the link:
subject: A pseudo file-uploader?
It's not a secret anymore!