You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by ma...@mail.bg on 2011/09/04 15:47:54 UTC

Know if FileUploadField has value set before its parent form is submitted and file gets uploaded



Hello, guys, 


I've got a FileUploadField as so: 


 image1UploadField = new FileUploadField("image1_upload", new Model()); 


I aim to know if the field has value set even before the form gets
processed and the item gets uploaded. I want to minimize traffic and memory
usage of my application. Therefore I don't want the file get uploaded
before I know if there really was file specified. 


What's the most proper way to do this in Wicket code? 


Thank you in advance,
Martin 

-------------------------------------
Mail.bg: Безплатен e-mail адрес. Най-добрите характеристики на българския пазар - 10 GB пощенска кутия, 20 MB прикрепен файл, безплатен POP3, мобилна версия, SMS известяване и други.

Re: Know if FileUploadField has value set before its parent form is submitted and file gets uploaded

Posted by Martin Grigorov <mg...@apache.org>.
Check https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/wicket-html5-parent/wicket-html5/src/main/java/org/wicketstuff/html5/fileapi
and its examples. But this uses HTML5 APIs and wont work on your
favorite Internet Explorer.

On Sun, Sep 4, 2011 at 7:35 PM, Christian Huber <hu...@butterbrot.org> wrote:
> Not sure if I completely understand what you want to do but as far as I do I
> guess the only way to do that is using java script.
>
> You could add a java script validation routine to the submit buttons onclick
> handler that aborts submission when the input field has no value.
>
> Another approach could be to add a onchange handler for the input field. If
> the field has a value set after a change the submit button gets enabled
> otherwise it can be disabled.
>
> hth, Chris
>
>
> The Sanity Resort <http://sanityresort.blogspot.com/>
>
> Am 04.09.2011 15:47, schrieb martin.asenov@mail.bg:
>>
>>
>> Hello, guys,
>>
>>
>> I've got a FileUploadField as so:
>>
>>
>>  image1UploadField = new FileUploadField("image1_upload", new Model());
>>
>>
>> I aim to know if the field has value set even before the form gets
>> processed and the item gets uploaded. I want to minimize traffic and
>> memory
>> usage of my application. Therefore I don't want the file get uploaded
>> before I know if there really was file specified.
>>
>>
>> What's the most proper way to do this in Wicket code?
>>
>>
>> Thank you in advance,
>> Martin
>>
>> -------------------------------------
>> Mail.bg: Безплатен e-mail адрес. Най-добрите характеристики на българския
>> пазар - 10 GB пощенска кутия, 20 MB прикрепен файл, безплатен POP3, мобилна
>> версия, SMS известяване и други.
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: Know if FileUploadField has value set before its parent form is submitted and file gets uploaded

Posted by Christian Huber <hu...@butterbrot.org>.
Not sure if I completely understand what you want to do but as far as I 
do I guess the only way to do that is using java script.

You could add a java script validation routine to the submit buttons 
onclick handler that aborts submission when the input field has no value.

Another approach could be to add a onchange handler for the input field. 
If the field has a value set after a change the submit button gets 
enabled otherwise it can be disabled.

hth, Chris


The Sanity Resort <http://sanityresort.blogspot.com/>

Am 04.09.2011 15:47, schrieb martin.asenov@mail.bg:
>
>
> Hello, guys,
>
>
> I've got a FileUploadField as so:
>
>
>   image1UploadField = new FileUploadField("image1_upload", new Model());
>
>
> I aim to know if the field has value set even before the form gets
> processed and the item gets uploaded. I want to minimize traffic and memory
> usage of my application. Therefore I don't want the file get uploaded
> before I know if there really was file specified.
>
>
> What's the most proper way to do this in Wicket code?
>
>
> Thank you in advance,
> Martin
>
> -------------------------------------
> Mail.bg: Безплатен e-mail адрес. Най-добрите характеристики на българския пазар - 10 GB пощенска кутия, 20 MB прикрепен файл, безплатен POP3, мобилна версия, SMS известяване и други.