I think that would like to have your class name (Document) here instead of
UploadPage, no?

<td>File Size:</td><td><span jwcid="@Insert" value="ognl:fileSize" format="
ognl:@[EMAIL PROTECTED]"/>&nbsp;bytes</td>

Cheers,
PS


On 3/20/06, Dwi Ardi Irawan <[EMAIL PROTECTED]> wrote:
>
> i'm a newbie
> i have tried upload in the tapestry Tapestry Component Reference.
> but i've got some error :
>
>       org.apache.tapestry.ApplicationRuntimeException
>       Could not load class UploadPage from [EMAIL 
> PROTECTED](file:/C:/my%20workspace/eols/webapp/WEB-INF/classes/)
> --parent--> [EMAIL PROTECTED]: UploadPage
>
>       could anyone help me ?
>       this is the code :
>
>       Documents.java
>
>       
> ===============================================================================================
>
> package edu.eols.web.page;
>
> import java.io.File;
> import java.io.FileOutputStream;
> import java.io.IOException;
> import java.io.InputStream;
> import java.text.Format;
> import java.text.NumberFormat;
>
> import org.apache.tapestry.IRequestCycle;
> import org.apache.tapestry.html.BasePage;
> import org.apache.tapestry.request.IUploadFile;
>
> public class Documents 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 String getFilename() {
>         if (file != null) {
>             return file.getFileName();
>         } else {
>             return "";
>         }
>     }
>
>     public String getClientPath() {
>         if (file != null) {
>             return file.getFilePath();
>         } else {
>             return "";
>         }
>     }
>
>     public String getServerPath() {
>         if (serverFile != null) {
>             return serverFile.getAbsolutePath();
>         } else {
>             return "";
>         }
>     }
>
>     public long getFileSize() {
>         if (serverFile != null) {
>             return serverFile.length();
>         } else {
>             return 0;
>         }
>     }
>
>     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;
>     }
>
> }
>
>
> ============================================================================
> Documents.html
> <form jwcid="@Form" listener="ognl:listeners.formSubmit">
>
> <table width="100%" border="0">
>
> <tr>
>
> <td colspan="2">File:&nbsp;<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>
>
> <tr>
>
> <td>Filename:</td><td><span jwcid="@Insert" value="ognl:filename"/></td>
>
> </tr>
>
> <tr>
>
> <td>Client path:</td><td><span jwcid="@Insert"
> value="ognl:clientPath"/></td>
>
> </tr>
>
> <tr>
>
> <td>Server Path:</td><td><span jwcid="@Insert"
> value="ognl:serverPath"/></td>
>
> </tr>
>
> <tr>
>
> <td>File Size:</td><td><span jwcid="@Insert" value="ognl:fileSize"
> format="ognl:@[EMAIL PROTECTED]"/>&nbsp;bytes</td>
>
> </tr>
>
> </table>
>
> </form>
>
>
>
> ================================================================
>
> Documents.page
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE page-specification PUBLIC
>   "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
>   "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
> <!-- generated by Spindle, http://spindle.sourceforge.net -->
>
> <page-specification class="edu.eols.web.page.Documents">
>
>     <description>add a description</description>
>     <context-asset name="home_01" path="/images/home_01.gif"/>
>     <context-asset name="home_02" path="/images/home_02.gif"/>
>     <context-asset name="home_03" path="/images/home_03.gif"/>
>     <context-asset name="home_04" path="/images/home_04.gif"/>
>     <context-asset name="home_05" path="/images/home_05.gif"/>
>     <context-asset name="home_06" path="/images/home_06.gif"/>
>     <context-asset name="home_07" path="/images/home_07.gif"/>
>
>
>
> </page-specification>
>
>
>
>
> ====================================================================
>
> eosl.application
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE application PUBLIC
>   "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
>   "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd";>
> <!-- generated by Spindle, http://spindle.sourceforge.net -->
>
> <application name="eols" engine-class="
> org.apache.tapestry.engine.BaseEngine">
>
>     <description>add a description</description>
>     <page name="Home" specification-path="Documents.page"/>
>     <extension name="org.apache.tapestry.multipart-decoder" class="
> org.apache.tapestry.multipart.DefaultMultipartDecoder">
>        <configure property-name="maxSize" type="double"
> value="134217728"/>
>     </extension>
>
>
> </application>
>
>

Reply via email to