You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by d s <dt...@yahoo.com> on 2005/02/18 15:24:46 UTC
Upload component - .page code
I need the upload to get working Please help
Here is my Html
<form jwcid="@Form"
listener="ognl:listener.formSubmit">
<table bgcolor="#c0c0c0" cellpadding="4">
<tr>
<td colspan="2">File: <input jwcid="@Upload"
file="ognl:file" type= "file"></input></td>
</tr>
<tr>
<td colspan="2"><input type=
"submit"value="Upload"></input></td>
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
</table>
</form>
I need the .Page, I tried several times..
And here is my java code
public class UploadPage extends BasePage {
public static final Format SIZE_FORMAT =
NumberFormat.getNumberInstance();
private IUploadFile file;
private File serverFile;
public IUploadFile getFile() { return file; }
public void setFile(IUploadFile value) {
file = value;
}
public void formSubmit(IRequestCycle cycle) {
InputStream fis = file.getStream();
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new
File(file.getFileName()));
byte[] buffer = new byte[1024];
while (true) {
int length = fis.read(buffer);
if (length < 0) {
break;
}
fos.write(buffer, 0, length);
}
fis.close();
fos.close();
serverFile = new File(file.getFileName());
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
if (fis != null) {
try { fis.close(); } catch
(IOException ioe) {}
}
if (fos != null) {
try { fos.close(); } catch
(IOException ioe) {}
}
}
}
protected void initialize() {
file = null;
serverFile = null;
}
}
__________________________________
Do you Yahoo!?
Take Yahoo! Mail with you! Get it on your mobile phone.
http://mobile.yahoo.com/maildemo
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Upload component - .page code
Posted by The Chris Method <th...@gmail.com>.
What's the problem? I do noticed that in the listener parameter of
your Form component, you forget the last 's' at the end of
"listeners".
It should be listener="ognl:listeners.formSubmit"
not
listener="ognl:listener.formSubmit"
On Fri, 18 Feb 2005 06:24:46 -0800 (PST), d s <dt...@yahoo.com> wrote:
> I need the upload to get working Please help
> Here is my Html
> <form jwcid="@Form"
> listener="ognl:listener.formSubmit">
> <table bgcolor="#c0c0c0" cellpadding="4">
> <tr>
> <td colspan="2">File: <input jwcid="@Upload"
> file="ognl:file" type= "file"></input></td>
> </tr>
> <tr>
> <td colspan="2"><input type=
> "submit"value="Upload"></input></td>
> </tr>
> <tr>
> <td colspan="2"><hr></td>
> </tr>
> </table>
> </form>
>
> I need the .Page, I tried several times..
>
> And here is my java code
> public class UploadPage extends BasePage {
> public static final Format SIZE_FORMAT =
> NumberFormat.getNumberInstance();
> private IUploadFile file;
> private File serverFile;
>
> public IUploadFile getFile() { return file; }
>
> public void setFile(IUploadFile value) {
> file = value;
> }
>
> public void formSubmit(IRequestCycle cycle) {
> InputStream fis = file.getStream();
> FileOutputStream fos = null;
>
> try {
> fos = new FileOutputStream(new
> File(file.getFileName()));
> byte[] buffer = new byte[1024];
> while (true) {
> int length = fis.read(buffer);
> if (length < 0) {
> break;
> }
> fos.write(buffer, 0, length);
>
> }
> fis.close();
> fos.close();
> serverFile = new File(file.getFileName());
>
> } catch (IOException ioe) {
> ioe.printStackTrace();
> } finally {
> if (fis != null) {
> try { fis.close(); } catch
> (IOException ioe) {}
> }
> if (fos != null) {
> try { fos.close(); } catch
> (IOException ioe) {}
> }
> }
> }
>
> protected void initialize() {
> file = null;
> serverFile = null;
> }
> }
>
> __________________________________
> Do you Yahoo!?
> Take Yahoo! Mail with you! Get it on your mobile phone.
> http://mobile.yahoo.com/maildemo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org