Hi.
Yes i have enable all; this is my cocoon-servlet configuration in web.xml:
<servlet>
<servlet-name>Cocoon</servlet-name>
<display-name>Cocoon</display-name>
<description>Cocoon</description>
<servlet-class>org.apache.cocoon.servlet.CocoonServlet</servlet-class>
<init-param>
<param-name>init-classloader</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>configurations</param-name>
<param-value>/WEB-INF/cocoon.xconf</param-value>
</init-param>
<init-param>
<param-name>logkit-config</param-name>
<param-value>/WEB-INF/logkit.xconf</param-value>
</init-param>
<init-param>
<param-name>servlet-logger</param-name>
<param-value>access</param-value>
</init-param>
<init-param>
<param-name>cocoon-logger</param-name>
<param-value>core</param-value>
</init-param>
<init-param>
<param-name>log-level</param-name>
<param-value>WARN</param-value>
</init-param>
<init-param>
<param-name>allow-reload</param-name>
<param-value>no</param-value>
</init-param>
<init-param>
<param-name>load-class</param-name>
<param-value>org.hsqldb.jdbcDriver</param-value>
</init-param>
<init-param>
<param-name>enable-uploads</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>upload-directory</param-name>
<param-value>XPDL</param-value>
</init-param>
<init-param>
<param-name>autosave-uploads</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>overwrite-uploads</param-name>
<param-value>rename</param-value>
</init-param>
<init-param>
<param-name>manage-exceptions</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
This is my form definition:
<?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/xml" required="true">
<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>
and this is my flow script:
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( "Ho ottenuto: ["+uploadWidget+"]" );
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;
}
I have started from cocoon samples. The proble is that even if i choose a file
.xml the content of my input is null so i have a null pointer exception.. i
really don't understand why.
---------- Initial Header -----------
>From : "Johannes Textor" [EMAIL PROTECTED]
To : [EMAIL PROTECTED]
Cc :
Date : Wed, 15 Dec 2004 09:34:20 +0100
Subject : Re: Cocoon File upload HELP
> did you enable file uploads in web.xml and set the upload path
> accordingly ?
>
> angeloimm wrote:
>
> >Hi... first of all thanks for your help.
> >I have tried to do what you said but i have always that error..... any ither
> >ideas?
> >Thanks
> >
> >---------- Initial Header -----------
> >
> >>From : "Mark Lundquist" [EMAIL PROTECTED]
> >To : [EMAIL PROTECTED]
> >Cc :
> >Date : Tue, 14 Dec 2004 13:57:50 -0800
> >Subject : Re: Cocoon File upload HELP
> >
> >
> >
> >>On Dec 14, 2004, at 9:43 AM, angeloimm wrote:
> >>
> >>
> >>
> >>> <ft:widget id="upload">
> >>> <fi:upload />
> >>> </ft:widget>
> >>>
> >>>
> >>Hi,
> >>
> >>Get rid of that <fi:upload/>.
> >>
> >>cheers,
> >>Mark
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >>
> >>
> >
> >
> >
> >____________________________________________________________
> >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: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
____________________________________________________________
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]