David Delbecq wrote:
If you want to keep the filepath in the form presented to user, it's
impossible. This is because for security reason it's impossible in HTML
to initialize a fileupload field. (Imagine a hidden file upload field
which send user confidnetial datas to a malicious server...). However,
the fileupload UIComponent keep it's internal value after the form is
reshown. I think if you don't upload a new value, the component will use
the old one.
  
Hi David and thanks for the reply,

The problem is that the UploadedFile attribute is set to null, as the form is reshown. And if I don't upload a new value nothing is uploaded.
Is there any other way to obtain the component's internal value you mentioned?

I also found this:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Saving upload despite any validation errors

In many cases you will want to save the uploaded file, even if there are validation errors. Otherwise the user must upload the file again, which is annoying and may be very time-consuming. To do that, don't value-bind the component to a backing bean, but use a ValueChangeListener and set immediate="true".

<t:inputFileUpload storage="file" immediate="true">
        <f:valueChangeListener type="com.myorg.foo.UploadListener" />
</t:inputFileUpload>
public class UploadListener implements ValueChangeListener {
        public void processValueChange(ValueChangeEvent event) throws AbortProcessingException {
                UploadedFile uploadedFile = (UploadedFile) event.getNewValue();
                
                // do something with uploadedFile
        }
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

But the problem is that the user won't see (when the page is reshown) the path of the file that will be uploaded.


Regards,
Elenh.





Reply via email to