You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Boulanger Martin <Ma...@atosorigin.com> on 2007/11/09 12:03:02 UTC
T5 - Upload File Component : NullPointerException
Hello,
I would like to upload a file using a tapestry form. I have followed the
example presented here:
http://tapestry.apache.org/tapestry5/tapestry-upload/
HTML :
<t:form>
<t:errors/>
<input t:type="upload" t:id="file" validate="required"/>
<br/>
<input type="submit" value="Upload"/>
</t:form>
JAVA :
public class UploadExample
{
private UploadedFile _file;
public UploadedFile getFile()
{
return _file;
}
public void setFile(UploadedFile file)
{
_file = file;
}
public void onSuccess()
{
File copied = new File("/my/file/location/" +
_file.getFileName());
_file.write(copied);
}
}
But when I try to access the page, I get a
java.lang.NullPointerException. And I don't understand which variable
should be initialized.
I used FileUpload 1.2
org.apache.tapestry.ioc.internal.util.TapestryException
location
classpath:... / UploadExample.html, line 13, column 65
8
</head>
9
10
<body>
11
<t:form>
12
<t:errors/>
13
<input t:type="upload" t:id="file" validate="required"/>
14
<br/>
15
<input type="submit" value="Upload"/>
16
</t:form>
17
</body>
18
</html>
java.lang.NullPointerException
Stack trace
*
org.apache.tapestry.upload.components.Upload.beginRender(Upload.java:146
)
*
org.apache.tapestry.upload.components.Upload.beginRender(Upload.java)
*
org.apache.tapestry.internal.structure.ComponentPageElementImpl$10$1.run
(ComponentPageElementImpl.java:345)
*
org.apache.tapestry.internal.structure.ComponentPageElementImpl.invoke(C
omponentPageElementImpl.java:931)
*
org.apache.tapestry.internal.structure.ComponentPageElementImpl.access$1
00(ComponentPageElementImpl.java:69)
* ......
Does someone knows how to solve this ?
Thank you very much,
Martin