You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "martijn.list" <ma...@gmail.com> on 2014/12/05 19:41:55 UTC

File selected for upload is cleared when page validation fails [T5.4]

Hi,

I have a form which contains an Upload component and some other fields.

If I select a file for upload and submit the form and the page
validation fails (for example because I forgot to fill in some required
field), the selected file is no longer selected.

Is this by design? The other fields are retained on a validation error.

I'm Using Tapestry 5.4b22

Kind regards,

Martijn Brinkers

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: File selected for upload is cleared when page validation fails [T5.4]

Posted by Bob Harner <bo...@gmail.com>.
Martijn,

For most common scenarios the best fix is to do sufficient validation on
the client (JavaScript) that the server side validation is not likely to
fail. Going further, you could store the uploaded file *before* the
validation fails, and then only display the file's name, rather than the
input type=file element, when displaying the form with validation errors.

You may find that these scenarios are handled much better in Ajax-based
file upload approaches, such as the Fine File Uploader (formerly Valums).
There are Tapestry integrations, such as https://github.com/FineUploader
On Dec 5, 2014 1:42 PM, "martijn.list" <ma...@gmail.com> wrote:

> Hi,
>
> I have a form which contains an Upload component and some other fields.
>
> If I select a file for upload and submit the form and the page
> validation fails (for example because I forgot to fill in some required
> field), the selected file is no longer selected.
>
> Is this by design? The other fields are retained on a validation error.
>
> I'm Using Tapestry 5.4b22
>
> Kind regards,
>
> Martijn Brinkers
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: File selected for upload is cleared when page validation fails [T5.4]

Posted by "martijn.list" <ma...@gmail.com>.
On 12/06/2014 06:21 PM, Howard Lewis Ship wrote:
> It's a very deliberate security design implement by all browsers otherwise
> a invisible hidden form field could read any file on your filesystem

Yes you are completely right.

Note to self: don't ask question if you are too tired to think

Kind regards,

Martijn


> 
> On Friday, December 5, 2014, Thiago H de Paula Figueiredo <
> thiagohp@gmail.com> wrote:
> 
>> On Fri, 05 Dec 2014 16:41:55 -0200, martijn.list <ma...@gmail.com>
>> wrote:
>>
>>  Hi,
>>>
>>
>> Hi!
>>
>>  I have a form which contains an Upload component and some other fields.
>>>
>>> If I select a file for upload and submit the form and the page
>>> validation fails (for example because I forgot to fill in some required
>>> field), the selected file is no longer selected.
>>>
>>> Is this by design? The other fields are retained on a validation error.
>>>
>>
>> This is how HTML's <input type="file"> works. It doesn't allow you to give
>> it an initial value.
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 


-- 
CipherMail email encryption

Open source email encryption gateway with support for S/MIME, OpenPGP
and PDF messaging.

http://www.ciphermail.com

Twitter: http://twitter.com/CipherMail

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: File selected for upload is cleared when page validation fails [T5.4]

Posted by Howard Lewis Ship <hl...@gmail.com>.
It's a very deliberate security design implement by all browsers otherwise
a invisible hidden form field could read any file on your filesystem

On Friday, December 5, 2014, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, 05 Dec 2014 16:41:55 -0200, martijn.list <ma...@gmail.com>
> wrote:
>
>  Hi,
>>
>
> Hi!
>
>  I have a form which contains an Upload component and some other fields.
>>
>> If I select a file for upload and submit the form and the page
>> validation fails (for example because I forgot to fill in some required
>> field), the selected file is no longer selected.
>>
>> Is this by design? The other fields are retained on a validation error.
>>
>
> This is how HTML's <input type="file"> works. It doesn't allow you to give
> it an initial value.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com
@hlship

Re: File selected for upload is cleared when page validation fails [T5.4]

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 05 Dec 2014 16:41:55 -0200, martijn.list <ma...@gmail.com>  
wrote:

> Hi,

Hi!

> I have a form which contains an Upload component and some other fields.
>
> If I select a file for upload and submit the form and the page
> validation fails (for example because I forgot to fill in some required
> field), the selected file is no longer selected.
>
> Is this by design? The other fields are retained on a validation error.

This is how HTML's <input type="file"> works. It doesn't allow you to give  
it an initial value.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org