You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Geoff Howard <co...@leverageweb.com> on 2003/11/01 15:48:03 UTC

Re: Flowscript, upload and Part probelm

Stephan Coboos wrote:
> Hello,
> 
> I'm trying to implement an upload using flowscript, but it doesn't work.
> Yes, I know the examples on the wiki and the mailling lists, but these
> examples dont work on my Cocoon (2.1.2). After I had submit the form, the
> request will not be converted to a Part Object, so I can't call a method
> like getSize() for example.
> 
> These are my files...

Do you have uploads enabled in web.xml?  What happens if you do

function main() {

   var part = cocoon.request.get("uploadFile");
   // part.getSize() doesnt work !!!
   // Probably will print "java.lang.String"
   java.lang.System.out.println(part.getClass().getName());
   cocoon.sendPage("index.jxt", {"value":part.getSize()});
}

Geoff


> -- My upload template (form.jxt):
> 
> <html>
> <head>
> <title>UploadTest</title>
> </head>
> <body>
> <form action="function" method="POST" enctype="multipart/form-data">
>   <input type="file" name="uploadFile"/>
>   <input type="submit"/>
> </form>
> </body>
> </html>
> 
> -- My Pipelines:
> 
> <map:pipeline>
>     <map:match pattern="function">
>       <map:call function="main"/>
>     </map:match>
> 
>     <map:match pattern="*.kont">
>       <map:call continuation="{1}"/>
>     </map:match>
> 
>     <map:match pattern="*.jxt">
>       <map:generate type="jxt" src="documents/{1}.jxt"/>
>       <map:serialize type="xhtml"/>
>     </map:match>
>   </map:pipeline>
> 
> -- My flowscript (main.js):
> 
> function main() {
> 
>   var part = cocoon.request.get("uploadFile");
>   // part.getSize() doesnt work !!!
>   cocoon.sendPage("index.jxt", {"value":part.getSize()});
> }
> 
> -- My result page (index.jxt):
> 
> <html>
> <head>
> <title>UploadTest</title>
> </head>
> <body>
> <b>${value}</b>
> </body>
> </html>
> 
> At first of all I call "/form.jxt" to display the form. The form calls after
> the submit "/function". The flowscript and all other pages works fine but
> using the method getSize() for example causes an Exception:
> 
> Original Exception: TypeError: getSize is not a function.
> (file:/E:/tomcat-4.1.27/webapps/cocoon/upload/flows/main.js; line 7)
> 
> at
> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:581)
> 
> at
> org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:541)
> 
> at org.mozilla.javascript.NativeGlobal.typeError1(NativeGlobal.java:551)
> 
> at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1234)
> 
> at
> org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(Conti
> nuationInterpreter.java:1104)
> 
> at
> org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(Conti
> nuationInterpreter.java:190)
> 
> at
> org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(Conti
> nuationInterpreter.java:138)
> 
> at
> org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(Interprete
> dFunctionImpl.java:121)
> <SCHNIPP/>
> 
> But the method getSize() exists on the abstract class
> org.apache.cocoon.servlet.multipart.Part class!
> 
> Please help me! Whats wrong here? Thank you!
> 
> Regards
> Stephan
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 
> 



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