Hi Søren,
I've checked the upload and can't find problems. The
reference/upload.jsp file in the demo is not full functional yet. So I
added some stuff. You may apply these changes on tobago-example-demo on
your system and look if it works fine or at any differences.
Hope that helps.
Regards
Udo
------------------------------------------------------------------
reference/upload.jsp
<tx:file label="Upload file:" value="#{upload.file}" />
<tc:button label="Submit" defaultCommand="true"
action="#{upload.upload}" />
------------------------------------------------------------------
faces-config.xml
<managed-bean>
<managed-bean-name>upload</managed-bean-name>
<managed-bean-class>org.apache.myfaces.tobago.example.reference.Upload</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
------------------------------------------------------------------
Upload.java (new)
package org.apache.myfaces.tobago.example.reference;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class Upload {
private static final Log LOG = LogFactory.getLog(Upload.class);
private FileItem file;
public String upload() {
LOG.info("type=" + file.getContentType());
LOG.info("file=" + file.get().length);
LOG.info("name=" + file.getName());
return null;
}
public FileItem getFile() {
return file;
}
public void setFile(FileItem file) {
this.file = file;
}
}
------------------------------------------------------------------
Søren Hjarlvig schrieb:
Hi,
I'm attempting to use the tc:file / tx:file control to upload a file.
But when I click the button responsible for submitting the page the
associated action is not invoked, the page is refreshed and showed
without any styles (!?).
Without the tx:file-tag everything works fine.
JSP:
<tx:file value="#{controller.fileItem}" required="false" label="Upload
file" />
<tc:button action="#{controller.save}" label="Save"/>
I have added the following to my web.xml:
<filter>
<filter-name>multipartFormdataFilter</filter-name>
<filter-class>org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter</filter-class>
<init-param>
<description>Set the size limit for uploaded
files...</description>
<param-name>uploadMaxFileSize</param-name>
<param-value>20m</param-value>
</init-param>
<init-param>
<description>Set the upload repository path for uploaded
files. Default value is java.io.tmpdir.</description>
<param-name>uploadRepositoryPath</param-name>
<param-value>c:/tmp</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>multipartFormdataFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
There are no errors or warnings, the debug log says:
...
DEBUG 21 okt 16:38:30
org.apache.myfaces.tobago.webapp.TobagoMultipartFormdataFilter -
Wrapping org.apache.catalina.connector.RequestFacade with
ContentType="multipart/form-data;
boundary=---------------------------209722283024901" into
TobagoMultipartFormdataRequest
...
DEBUG 21 okt 16:38:30
org.apache.myfaces.tobago.renderkit.html.scarborough.standard.tag.FileRenderer
- Uploaded file name : "image001.gif" size = 5558
...
I'm using Tobago 1.0.23 / MyFaces 1.1.6 / Tomcat 6.0.20 / Java 6u15.
I hope someone can provide a hint. Thanks.
Best regards
Soeren