You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ael <al...@dash.com.ph> on 2011/06/10 04:45:03 UTC

T5.2.5 Error uploading file using FORM with ID will generate NPE.

Error uploading file using FORM with ID.

File value is null.

TEMPLATE CLASS


<form t:type="form" t:id="guestForm">
</form>



PAGE CLASS


    @Component(id = "guestForm")
    private Form guestForm;

    @Property
    private UploadedFile file;

    public void onSuccessFromguestForm() {
        
        // Set Path
        String path = "C:/temp/";
        File copied;
        
        // Get File
        copied = new File(path + file.getFileName());
    }



--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-5-Error-uploading-file-using-FORM-with-ID-will-generate-NPE-tp4474992p4474992.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: T5.2.5 Error uploading file using FORM with ID will generate NPE.

Posted by ael <al...@dash.com.ph>.
Hi Thiago,

I dont know what happened but for now it is working.

Just CLEAN & BUILD...

Thanks :)

--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-5-Error-uploading-file-using-FORM-with-ID-will-generate-NPE-tp4474992p4482815.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: T5.2.5 Error uploading file using FORM with ID will generate NPE.

Posted by ael <al...@dash.com.ph>.
Hi Thiago,

The problem is it will not go to the onsuccess method but it will go to
onfail method
this is the real problem. But when i remove the id on the form the error
will not occur anymore.

Its kinda weird though.

Any idea whats happening here?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-5-Error-uploading-file-using-FORM-with-ID-will-generate-NPE-tp4474992p4482760.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: T5.2.5 Error uploading file using FORM with ID will generate NPE.

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 10 Jun 2011 01:22:05 -0300, ael <al...@dash.com.ph> wrote:

> What do you mean i should use the Upload component?

Oops, my mail reader somehow hadn't shown the Upload component being used,  
just an empty form. :P

> <t:form t:id="guestForm">
>         <t:errors/>
>         <input t:type="upload" t:id="file" validate="required"/>
>         <br/>
>         <input type="submit" value="Upload"/>
> </t:form>
>
> public class UploadExample
>     {
>         @Property
>         private UploadedFile file;
>
>         @Component(id = "guestForm")
>         private Form guestForm;
>
>         public void onSuccessFromguestForm()
>         {
>             File copied = new File("/my/file/location/" +
> file.getFileName());
>            file.write(copied);
>         }
>     }

Your code seems fine besides the fact it doesn't check if file is null,  
something that happens when the user doesn't select a file to upload.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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


Re: T5.2.5 Error uploading file using FORM with ID will generate NPE.

Posted by ael <al...@dash.com.ph>.
What do you mean i should use the Upload component?

I only based the code based on 
http://tapestry.apache.org/uploading-files.html
http://tapestry.apache.org/uploading-files.html 

Then i modified it based on Multiple FORM design.




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

public class UploadExample
    {
        @Property
        private UploadedFile file;

        @Component(id = "guestForm")
        private Form guestForm;

        public void onSuccessFromguestForm()
        {
            File copied = new File("/my/file/location/" +
file.getFileName());
            
            file.write(copied);
        }
    }




--
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-5-Error-uploading-file-using-FORM-with-ID-will-generate-NPE-tp4474992p4475147.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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


Re: T5.2.5 Error uploading file using FORM with ID will generate NPE.

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 09 Jun 2011 23:45:03 -0300, ael <al...@dash.com.ph> wrote:

> Error uploading file using FORM with ID.
> File value is null.
> TEMPLATE CLASS
>
> <form t:type="form" t:id="guestForm">
> </form>

You need to use the Upload component in your template.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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