You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Qbyte Consulting <qb...@gmail.com> on 2016/08/31 20:03:27 UTC

file upload doesn't set file value

Hi,

I'm always finding that file is null for file upload? If I submit the form
without async=true then file value is set and it works.

            <t:zone t:id="profileZone">

                <form t:type="form" t:id="uploadForm" async="true">
                    <t:errors/>
                    <input t:type="upload" t:id="file" t:value="file"
validate="required"/>
                    <input t:type="submit" value="Upload"/>
                </form>

    public void onValidateFromUploadForm() {
        if (file != null) {
            File copied = new File("./uploads/" + file.getFileName());
            file.write(copied);
         } else {
             System.out.println("upload failed");
        }
    }

Re: file upload doesn't set file value

Posted by Carlos Montero Canabal <ca...@gmail.com>.
For my experience, FileUpload doesn´t support ajax form (t:async="true" or t:zone=“^”).

Regards

Carlos Montero

> El 31/8/2016, a las 22:03, Qbyte Consulting <qb...@gmail.com> escribió:
> 
> Hi,
> 
> I'm always finding that file is null for file upload? If I submit the form
> without async=true then file value is set and it works.
> 
>            <t:zone t:id="profileZone">
> 
>                <form t:type="form" t:id="uploadForm" async="true">
>                    <t:errors/>
>                    <input t:type="upload" t:id="file" t:value="file"
> validate="required"/>
>                    <input t:type="submit" value="Upload"/>
>                </form>
> 
>    public void onValidateFromUploadForm() {
>        if (file != null) {
>            File copied = new File("./uploads/" + file.getFileName());
>            file.write(copied);
>         } else {
>             System.out.println("upload failed");
>        }
>    }


Re: [Ext] Re: file upload doesn't set file value

Posted by "D.R." <d....@googlemail.com.INVALID>.
one more hint for anyone who might run into to the same issue:

spring.http.multipart.enabled=false

worked for me


On 14.12.2017 20:55, Dongmei Cao wrote:
>
> Thanks for your example! Just for anyone who might run into to the 
> same issue. It was the SpringBoot causing the issue for our case (we 
> migrated to SpringBoot as we upgrade the Tapestry version). Had to 
> specify a Multipart File Size in SpringBoot to have it work properly.
>
> Dongmei
>
> *From: *yazmin georgina quintal <ge...@yahoo.com.mx>
> *Reply-To: *yazmin georgina quintal <ge...@yahoo.com.mx>
> *Date: *Wednesday, December 13, 2017 at 6:38 AM
> *To: *Tapestry users <us...@tapestry.apache.org>, Dongmei Cao 
> <do...@icann.org>
> *Subject: *Re: [Ext] Re: file upload doesn't set file value
>
> Do not know SpringBoot.
>
> I add my test page, but I do not see any difference with your, and my 
> dependency is simply
>
>         <dependency>
>  <groupId>org.apache.tapestry</groupId>
>  <artifactId>tapestry-upload</artifactId>
>             <version>5.4.3</version>
>         </dependency>
>
> On the browser, do you select the file to be send/post during your 
> test ? I know, really simply but ... I though this because the 
> required validation is probably been done on client side.
>
> Saludos.
>
> Atte. Yazmín Georgina Quintal Moo
>
> Local 63 y 64 de Plaza de la Tecnología. Villahermosa, Tab.
> Tel 993 1311688
> Cel. 9931 689207
>
> El martes, 12 de diciembre de 2017 21:45:56 GMT-6, Dongmei Cao 
> <do...@icann.org> escribió:
>
> 1) I have the following dependencies
>
> <dependency>
> <groupId>org.apache.tapestry</groupId>
> <artifactId>tapestry-upload</artifactId>
>     <version5.4.3version>
> </dependency>
>
> Tried with and without the following two. Didn’t make any difference:
>
> <dependency>
> <groupId>commons-fileupload</groupId>
> <artifactId>commons-fileupload</artifactId>
>     <version>1.3.2</version>
> </dependency>
>
> <dependency>
>     <groupId>commons-io</groupId>
> <artifactId>commons-io</artifactId>
>     <version>2.4</version>
> </dependency>
>
> 2) Since I have the validate="required" in the .tml, it always display 
> error message “You must provide a value for File”. It didn’t even get 
> to the onSuccess(). If I remove the validate="required", it got to the 
> onSuccess. But the file is null. So, yes, it throws NPE when trying 
> file.getFileName().
>
> 3) I’m using it with SpringBoot. Not sure if that will make any 
> difference.
>
> Thanks,
> Dongmei
>
>
> From: yazmin georgina quintal <geolita67@yahoo.com.mx 
> <ma...@yahoo.com.mx>>
> Reply-To: yazmin georgina quintal <geolita67@yahoo.com.mx 
> <ma...@yahoo.com.mx>>
> Date: Tuesday, December 12, 2017 at 5:20 PM
> To: Tapestry users <users@tapestry.apache.org 
> <ma...@tapestry.apache.org>>, Dongmei Cao 
> <dongmei.cao@icann.org <ma...@icann.org>>
> Subject: [Ext] Re: file upload doesn't set file value
>
> I am using it and it is working ok:
>
> 1. Did you add depedency to tapestry-fileupload module ?.
> 2. Does it throws a Null Pointer Exception or simply you do not see 
> then file created ?
> 3. The path in "copied" File instance must exist, the method write 
> will not create it.
>
> I recently begun to use it without trouble.
>
> Saludos.
> Atte. Yazmín Georgina Quintal Moo
> Local 63 y 64 de Plaza de la Tecnología. Villahermosa, Tab.
> Tel 993 1311688
> Cel. 9931 689207
>
>
> El martes, 12 de diciembre de 2017 18:37:49 GMT-6, Dongmei Cao 
> <dongmei.cao@icann.org <ma...@icann.org>> escribió:
>
>
> Hi,
>
> I know this is an old post. I’m trying to migrate our app from 5.3.8 
> to 5.4.3, and finding the file upload is no longer working. I’m not 
> using t:zone at all. But the file value is always null. I see the 
> JumpStart site 
> (http://jumpstart.doublenegative.com.au/jumpstart/[jumpstart.doublenegative.com.au] 
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__jumpstart.doublenegative.com.au_jumpstart_&d=DwMFaQ&c=FmY1u3PJp6wrcrwll3mSVzgfkbPSS6sJms7xcl4I5cM&r=2z1riFMXKMf_hbDJyPHriu7_4_IwytJZgQJzCNqy_QY&m=DugQdN_18mBr_zhiz9ftF7gXwnKLvxrvmztleDsgT6Q&s=KY6h9cN8_vKemdQm_tByZlMDqY46OaJkhPlRe45B_TQ&e=>[jumpstart.doublenegative.com.au]) 
> have the “File Upload” example disabled. Anyone has a working example. 
> Could you please share?
>
>
>
> <t:form>
>     <t:errors/>
>     <input t:type="upload" t:id="file" t:value="file" 
> validate="required"/> <br/>
>     <input type="submit" value="Upload"/>
> </t:form>
>
>
>     @Persist
>     @Property
>     private UploadedFile file;
>
>     public Object onSuccess() {
>         System.out.println(file.getFileName());
>         File copied = new File("/my/file/location/" + file.getFileName());
>         file.write(copied);
>
>         return this;
>     }
>
> Thanks,
> Dongmei
>
> On 9/1/16, 12:50 AM, "Chris Poulsen" <mailinglist@nesluop.dk 
> <ma...@nesluop.dk>> wrote:
>
>     Unfortunately I think Carlos is correct.
>
>     --
>     Chris
>
>     On Wed, Aug 31, 2016 at 11:18 PM, Pavel Chernyak 
> <fjfalcon@fjfalcon.ru <ma...@fjfalcon.ru>>
>     wrote:
>
>     > Hi there.
>     >
>     > Maybe you shall anotate field file @Persist?
>     >
>     >
>     > On 31 August 2016 at 23:03, Qbyte Consulting 
> <qbyteconsulting@gmail.com <ma...@gmail.com>>
>     > wrote:
>     >
>     > >
>     > > I'm always finding that file is null for file upload? If I 
> submit the
>     > form
>     > > without async=true then file value is set and it works.
>     > >
>     >
>     >
>     > --
>     > With best regards.
>     > Pavel Chernyak
>     >
>


Re: [Ext] Re: file upload doesn't set file value

Posted by Dongmei Cao <do...@icann.org>.
Thanks for your example! Just for anyone who might run into to the same issue. It was the SpringBoot causing the issue for our case (we migrated to SpringBoot as we upgrade the Tapestry version). Had to specify a Multipart File Size in SpringBoot to have it work properly.

 

Dongmei

 

From: yazmin georgina quintal <ge...@yahoo.com.mx>
Reply-To: yazmin georgina quintal <ge...@yahoo.com.mx>
Date: Wednesday, December 13, 2017 at 6:38 AM
To: Tapestry users <us...@tapestry.apache.org>, Dongmei Cao <do...@icann.org>
Subject: Re: [Ext] Re: file upload doesn't set file value

 

Do not know SpringBoot.

 

I add my test page, but I do not see any difference with your, and my dependency is simply

 

        <dependency>
            <groupId>org.apache.tapestry</groupId>
            <artifactId>tapestry-upload</artifactId>
            <version>5.4.3</version>
        </dependency>

 

On the browser, do you select the file to be send/post during your test ? I know, really simply but ... I though this because the required validation is probably been done on client side.

 

 

Saludos.

 

Atte. Yazmín Georgina Quintal Moo 

Local 63 y 64 de Plaza de la Tecnología. Villahermosa, Tab. 
Tel 993 1311688 
Cel. 9931 689207

 

 

El martes, 12 de diciembre de 2017 21:45:56 GMT-6, Dongmei Cao <do...@icann.org> escribió: 

 

 

1) I have the following dependencies

<dependency>
    <groupId>org.apache.tapestry</groupId>
    <artifactId>tapestry-upload</artifactId>
    <version5.4.3version>
</dependency>

Tried with and without the following two. Didn’t make any difference:

<dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.3.2</version>
</dependency>

<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>

2) Since I have the validate="required" in the .tml, it always display error message “You must provide a value for File”. It didn’t even get to the onSuccess(). If I remove the validate="required", it got to the onSuccess. But the file is null. So, yes, it throws NPE when trying file.getFileName().

3) I’m using it with SpringBoot. Not sure if that will make any difference.

Thanks,
Dongmei


From: yazmin georgina quintal <ge...@yahoo.com.mx>
Reply-To: yazmin georgina quintal <ge...@yahoo.com.mx>
Date: Tuesday, December 12, 2017 at 5:20 PM
To: Tapestry users <us...@tapestry.apache.org>, Dongmei Cao <do...@icann.org>
Subject: [Ext] Re: file upload doesn't set file value

I am using it and it is working ok:

1. Did you add depedency to tapestry-fileupload module ?.
2. Does it throws a Null Pointer Exception or simply you do not see then file created ?
3. The path in "copied" File instance must exist, the method write will not create it.

I recently begun to use it without trouble.

Saludos.
Atte. Yazmín Georgina Quintal Moo 
Local 63 y 64 de Plaza de la Tecnología. Villahermosa, Tab. 
Tel 993 1311688 
Cel. 9931 689207


El martes, 12 de diciembre de 2017 18:37:49 GMT-6, Dongmei Cao <do...@icann.org> escribió: 


Hi,

I know this is an old post. I’m trying to migrate our app from 5.3.8 to 5.4.3, and finding the file upload is no longer working. I’m not using t:zone at all. But the file value is always null. I see the JumpStart site (http://jumpstart.doublenegative.com.au/jumpstart/[jumpstart.doublenegative.com.au][jumpstart.doublenegative.com.au]) have the “File Upload” example disabled. Anyone has a working example. Could you please share? 



<t:form>
    <t:errors/>
    <input t:type="upload" t:id="file" t:value="file" validate="required"/> <br/>
    <input type="submit" value="Upload"/>
</t:form>


    @Persist
    @Property
    private UploadedFile file;

    public Object onSuccess() {
        System.out.println(file.getFileName());
        File copied = new File("/my/file/location/" + file.getFileName());
        file.write(copied);

        return this;
    }

Thanks,
Dongmei

On 9/1/16, 12:50 AM, "Chris Poulsen" <ma...@nesluop.dk> wrote:

    Unfortunately I think Carlos is correct.
    
    -- 
    Chris
    
    On Wed, Aug 31, 2016 at 11:18 PM, Pavel Chernyak <fj...@fjfalcon.ru>
    wrote:
    
    > Hi there.
    >
    > Maybe you shall anotate field file @Persist?
    >
    >
    > On 31 August 2016 at 23:03, Qbyte Consulting <qb...@gmail.com>
    > wrote:
    >
    > >
    > > I'm always finding that file is null for file upload? If I submit the
    > form
    > > without async=true then file value is set and it works.
    > >
    >
    >
    > --
    > With best regards.
    > Pavel Chernyak
    >
    


Re: [Ext] Re: file upload doesn't set file value

Posted by Dongmei Cao <do...@icann.org>.
1) I have the following dependencies

<dependency>
    <groupId>org.apache.tapestry</groupId>
    <artifactId>tapestry-upload</artifactId>
    <version5.4.3version>
</dependency>

Tried with and without the following two. Didn’t make any difference:

<dependency>
    <groupId>commons-fileupload</groupId>
    <artifactId>commons-fileupload</artifactId>
    <version>1.3.2</version>
</dependency>

<dependency>
    <groupId>commons-io</groupId>
    <artifactId>commons-io</artifactId>
    <version>2.4</version>
</dependency>

2) Since I have the validate="required" in the .tml, it always display error message “You must provide a value for File”. It didn’t even get to the onSuccess(). If I remove the validate="required", it got to the onSuccess. But the file is null. So, yes, it throws NPE when trying file.getFileName().

3) I’m using it with SpringBoot. Not sure if that will make any difference.

Thanks,
Dongmei


From: yazmin georgina quintal <ge...@yahoo.com.mx>
Reply-To: yazmin georgina quintal <ge...@yahoo.com.mx>
Date: Tuesday, December 12, 2017 at 5:20 PM
To: Tapestry users <us...@tapestry.apache.org>, Dongmei Cao <do...@icann.org>
Subject: [Ext] Re: file upload doesn't set file value

I am using it and it is working ok:

1. Did you add depedency to tapestry-fileupload module ?.
2. Does it throws a Null Pointer Exception or simply you do not see then file created ?
3. The path in "copied" File instance must exist, the method write will not create it.

I recently begun to use it without trouble.

Saludos.
Atte. Yazmín Georgina Quintal Moo 
Local 63 y 64 de Plaza de la Tecnología. Villahermosa, Tab. 
Tel 993 1311688 
Cel. 9931 689207


El martes, 12 de diciembre de 2017 18:37:49 GMT-6, Dongmei Cao <do...@icann.org> escribió: 


Hi,

I know this is an old post. I’m trying to migrate our app from 5.3.8 to 5.4.3, and finding the file upload is no longer working. I’m not using t:zone at all. But the file value is always null. I see the JumpStart site (http://jumpstart.doublenegative.com.au/jumpstart/[jumpstart.doublenegative.com.au]) have the “File Upload” example disabled. Anyone has a working example. Could you please share?

<t:form>
    <t:errors/>
    <input t:type="upload" t:id="file" t:value="file" validate="required"/> <br/>
    <input type="submit" value="Upload"/>
</t:form>


    @Persist
    @Property
    private UploadedFile file;

    public Object onSuccess() {
        System.out.println(file.getFileName());
        File copied = new File("/my/file/location/" + file.getFileName());
        file.write(copied);

        return this;
    }

Thanks,
Dongmei

On 9/1/16, 12:50 AM, "Chris Poulsen" <ma...@nesluop.dk> wrote:

    Unfortunately I think Carlos is correct.
    
    -- 
    Chris
    
    On Wed, Aug 31, 2016 at 11:18 PM, Pavel Chernyak <fj...@fjfalcon.ru>
    wrote:
    
    > Hi there.
    >
    > Maybe you shall anotate field file @Persist?
    >
    >
    > On 31 August 2016 at 23:03, Qbyte Consulting <qb...@gmail.com>
    > wrote:
    >
    > >
    > > I'm always finding that file is null for file upload? If I submit the
    > form
    > > without async=true then file value is set and it works.
    > >
    >
    >
    > --
    > With best regards.
    > Pavel Chernyak
    >
    


Re: file upload doesn't set file value

Posted by Dongmei Cao <do...@icann.org>.
Hi,

I know this is an old post. I’m trying to migrate our app from 5.3.8 to 5.4.3, and finding the file upload is no longer working. I’m not using t:zone at all. But the file value is always null. I see the JumpStart site (http://jumpstart.doublenegative.com.au/jumpstart/) have the “File Upload” example disabled. Anyone has a working example. Could you please share?

<t:form>
    <t:errors/>
    <input t:type="upload" t:id="file" t:value="file" validate="required"/> <br/>
    <input type="submit" value="Upload"/>
</t:form>


    @Persist
    @Property
    private UploadedFile file;

    public Object onSuccess() {
        System.out.println(file.getFileName());
        File copied = new File("/my/file/location/" + file.getFileName());
        file.write(copied);

        return this;
    }

Thanks,
Dongmei

On 9/1/16, 12:50 AM, "Chris Poulsen" <ma...@nesluop.dk> wrote:

    Unfortunately I think Carlos is correct.
    
    -- 
    Chris
    
    On Wed, Aug 31, 2016 at 11:18 PM, Pavel Chernyak <fj...@fjfalcon.ru>
    wrote:
    
    > Hi there.
    >
    > Maybe you shall anotate field file @Persist?
    >
    >
    > On 31 August 2016 at 23:03, Qbyte Consulting <qb...@gmail.com>
    > wrote:
    >
    > >
    > > I'm always finding that file is null for file upload? If I submit the
    > form
    > > without async=true then file value is set and it works.
    > >
    >
    >
    > --
    > With best regards.
    > Pavel Chernyak
    >
    

Re: file upload doesn't set file value

Posted by Chris Poulsen <ma...@nesluop.dk>.
Unfortunately I think Carlos is correct.

-- 
Chris

On Wed, Aug 31, 2016 at 11:18 PM, Pavel Chernyak <fj...@fjfalcon.ru>
wrote:

> Hi there.
>
> Maybe you shall anotate field file @Persist?
>
>
> On 31 August 2016 at 23:03, Qbyte Consulting <qb...@gmail.com>
> wrote:
>
> >
> > I'm always finding that file is null for file upload? If I submit the
> form
> > without async=true then file value is set and it works.
> >
>
>
> --
> With best regards.
> Pavel Chernyak
>

Re: file upload doesn't set file value

Posted by Pavel Chernyak <fj...@fjfalcon.ru>.
Hi there.

Maybe you shall anotate field file @Persist?


On 31 August 2016 at 23:03, Qbyte Consulting <qb...@gmail.com>
wrote:

>
> I'm always finding that file is null for file upload? If I submit the form
> without async=true then file value is set and it works.
>


-- 
With best regards.
Pavel Chernyak