That strange, i took a look at code involved. The upload is wrapped in
an UploadedFile at decode time. It is then sotred as submited value. I
thing the validation process move it to value (current value of
component, but not yet stored in backing bean until validation is fully
complete), this internal value is stored dureing the saveState() and
resotred during restoreState(). Is your JSF configured to store status
server-side or client side+?
Eleni Tsigka a écrit :
> 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
> <http://wiki.apache.org/myfaces/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.
>
>
>