David Delbecq wrote:
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.
Well, I use myFaces through seam (of JBOSS). I think that the status of
jsf is stored server-side. I cant't think how I could have configured
it to be stored client-side (if so it is my unintented mistake). I
don't that these data should be stored client-side.
I tried the code shown in my previous e-mail, and it partially works.
The valueChangeListener works fine and gives me the file to upload. The
obvious problem is that when the form is reshown (after a potential
validation error), if the user doesn't browse the file to upload again,
the valueChangeListener returns null. So I can't be sure which is the
desirable file.
Do you have something else in mind, that I can't understand about
getting the actual value from the UIComponent.
Thanks again,
Elenh
|
- Re: question on : How do I prevent reset of file path in <... Eleni Tsigka
-