cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "angeloimm" <angelo...@libero.it>
Subject Cocoon File upload HELP
Date Tue, 14 Dec 2004 17:43:41 GMT
Hi all.... i have this form.xml:

<?xml version="1.0"?>

<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
  <fd:widgets>
  
    <fd:field id="user" required="false">
      <fd:datatype base="string"/>
      <fd:label>Inserire il file XPDL da uploadare</fd:label>
    </fd:field>
    
    <fd:upload id="upload" mime-types="text/plain, text/xml" required="false">
      <fd:label>File da uploadare</fd:label>
      <fd:hint>Scegliere un file di tipo XPDL o XML</fd:hint>
    </fd:upload>
    
  </fd:widgets>
</fd:form>

this is my template:

<?xml version="1.0"?>
<page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" xmlns:ft="http://apache.org/cocoon/forms/1.0#template"
xmlns:fi="http://apache.org/cocoon/forms/1.0#instance">
    <jx:import uri="resource://org/apache/cocoon/forms/generation/template.jx"/>
  <title>Upload XPDL/XML file</title>
  <content>
    <para>Scegliere il descrittore XML o XPDL che si vuole caricare</para>
    <ft:form-template action="#{$cocoon/continuation/id}.kont" method="POST" enctype="multipart/form-data">
      <table>
        <tr>
          <td valign="top">
            <ft:widget-label id="user"/>
          </td>
        </tr>
        <tr>
          <td valign="top">
            <ft:widget-label id="upload"/>
          </td>
          <td valign="top">
            <ft:widget id="upload">
              <fi:upload />
            </ft:widget>
          </td>
        </tr>
      </table><br/>
      <input type="submit" value="Upload"/>
    </ft:form-template>
  </content>
</page>

in my flow-script i have this function (from the cocoon samples):

function upload() {

    var log = Logger.getLogger( "it.eng.nikko.workflow.upload.js" );
    log.info( "Sono quì" );
    var form = new Form("forms/uploadForm.xml");  
    var k = form.showForm("uploadFile.jx");
    log.info( "Starting upload......" );
    //k.invalidate();
  var uploadWidget = form.lookupWidget("upload");
  log.info( "uploadWidget.getValue(): "+ uploadWidget.getValue() );
  log.info( "uploadWidget.value: "+ uploadWidget.value );      
    var content = handleUpload(form);
    var fileName = form.lookupWidget("upload").getValue().getHeaders().get("filename");
    
    log.info( "Upload finished....." );

    cocoon.sendPage("uploadSuccess.jx",
        {
            uploadContent: content, 
            filename: fileName
        }
    );
}

function handleUpload(form) {

  var log = Logger.getLogger( "it.eng.nikko.workflow.upload.js" );
  log.info( "handleUpload" );
  var buf = new java.lang.StringBuffer();
  
  var uploadWidget = form.lookupWidget("upload");
  log.info( "uploadWidget.getValue(): "+ uploadWidget.getValue() );
  log.info( "uploadWidget.value: "+ uploadWidget.value );
  if (uploadWidget.getValue() != null) {
  log.info( "in if" );
    var realPath = java.lang.System.getProperty( "realPath" );
    var dir = new java.io.File( realPath+"/procDef/" ); 
    if( !dir.exists() ){
    
      dir.mkdirs();
    }
    var myFile = new java.io.File( dir,  getFileName( uploadWidget.getValue() ) );
    var writer = new java.io.PrintWriter ( new java.io.FileOutputStream( myFile ) );
    var stream = uploadWidget.getValue().getInputStream();
    
    var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream));

    var line;
    while ((line=reader.readLine())!=null){
    
       buf.append(line).append("\n");
       writer.println( line );
    }

    reader.close();
    writer.close();
    UploadXPDL.doUpload( myFile );
  }else{
  
    log.info( "Era nullo" );
  }
  
  return buf.toString();
}

function getFileName( path ){

   var strTok = new java.util.StringTokenizer( path,"/" );
   var workFlowFile = null;
   while( strTok.hasMoreTokens() ){
 
     var token = strTok.nextToken();
     if( ( token.indexOf( ".xml" ) > -1 ) || ( token.indexOf( ".xpdl" ) > -1 ) ){
       workFlowFile = token;
     }
   }
   return workFlowFile;
}

Well when i try to do upload i have:

2004-12-14 18:34:52,556 INFO  [it.eng.nikko.workflow.upload.js] Sono quì
2004-12-14 18:35:21,828 INFO  [it.eng.nikko.workflow.upload.js] Starting upload......
2004-12-14 18:35:21,828 INFO  [it.eng.nikko.workflow.upload.js] uploadWidget.getValue(): null
2004-12-14 18:35:21,828 INFO  [it.eng.nikko.workflow.upload.js] uploadWidget.value: null
2004-12-14 18:35:21,828 INFO  [it.eng.nikko.workflow.upload.js] handleUpload
2004-12-14 18:35:21,828 INFO  [it.eng.nikko.workflow.upload.js] uploadWidget.getValue(): null
2004-12-14 18:35:21,828 INFO  [it.eng.nikko.workflow.upload.js] uploadWidget.value: null
2004-12-14 18:35:21,828 INFO  [it.eng.nikko.workflow.upload.js] Era nullo

While the stack trace is:
ERROR   (2004-12-14) 18:35.21:898   [access] (/Nikko/WorkFlowUpload/2558681a541780226919057a755d0e874216886c.kont)
http-0.0.0.0-8080-Processor24/CocoonServlet: Internal Cocoon Problem
org.apache.avalon.framework.CascadingRuntimeException: Cannot convert null to an object.
	at org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(Unknown
Source)
	at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(Unknown Source)
	at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(Unknown Source)
	at org.apache.cocoon.Cocoon.process(Unknown Source)
	at org.apache.cocoon.servlet.CocoonServlet.service(Unknown Source)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:72)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:275)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
	at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
	at java.lang.Thread.run(Thread.java:534)
Caused by: TypeError: Cannot convert null to an object. (file:/C:/jboss-3.2.5/server/mySever/tmp/deploy/tmp4713NikkoCM.war/WorkFlowUpload/flow/upload.js;
line 195)
	at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:581)
	at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:541)
	at org.mozilla.javascript.NativeGlobal.typeError0(NativeGlobal.java:546)
	at org.mozilla.javascript.ScriptRuntime.toObject(ScriptRuntime.java:497)
	at org.mozilla.javascript.ScriptRuntime.toObject(ScriptRuntime.java:473)
	at org.mozilla.javascript.ScriptRuntime.getProp(ScriptRuntime.java:711)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:694)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:190)
	at org.mozilla.javascript.continuations.ContinuationInterpreter.interpret(ContinuationInterpreter.java:138)
	at org.mozilla.javascript.continuations.InterpretedFunctionImpl.call(InterpretedFunctionImpl.java:121)
	at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1244)
	at org.mozilla.javascript.ScriptableObject.callMethod(ScriptableObject.java:1591)
	... 50 more
Can anybody help me?
Thanks.....



____________________________________________________________
Libero ADSL: 3 mesi gratis e navighi a 1.2 Mega, senza costi di attivazione.
Abbonati subito su http://www.libero.it



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


Mime
View raw message