Version 7


    1. You need 2 Seam components. A "backing bean" required by Tomahawk and SLSB to deal with your JSF action:


    1a. Backing Bean:


    public class UploadBackingBean {
        private UploadedFile file;
        public void setFile(UploadedFile file) {
            this.file = file;
        public UploadedFile getFile() {
            return this.file;


    1b. Action and its interface


    public class UploadAction implements Upload {
        private Logger logger;
         * O arquivo que foi enviado.
        private UploadBackingBean uploadBean;
        private FacesContext facesContext;
        public void init() {
            logger = Logger.getLogger(this.getClass());
        public String upload() {
            UploadedFile file = uploadBean.getFile();
            logger.debug("Abrindo o arquivo como DOM4J");
            facesContext.addMessage(null, new FacesMessage("Nome do arquivo: "
                    + file.getName()));
            return "success";


    public interface Upload {
        public String upload();


    2. You need to define a tomahawk.taglib.xml if you want to be able to access your tomahawk upload component via facelets. It shoud go in your .war WEB-INF


    <?xml version="1.0"?>
    <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "facelet-taglib_1_0.dtd">
        <!-- author: -->


    A full taglib definition is available here:


    3. Apart from the normal Seam stuff in your web.xml you need to reference whatever is that Tomahawk needs:


         <!-- My Faces Extensions Filter -->
                <description>Set the size limit for uploaded files.
                    Format: 10 - 10 bytes
                            10k - 10 KB
                            10m - 10 MB
                            1g - 1 GB
                <description>Set the threshold size - files
                        below this limit are stored in memory, files above
                        this limit are stored on disk.
                    Format: 10 - 10 bytes
                            10k - 10 KB
                            10m - 10 MB
                            1g - 1 GB
                <description>Set the path where the intermediary files will be stored.
         <!-- MyFaces Tomahawk Library -->


    4. The HTML would look something like this:


    <h:form enctype="multipart/form-data">
         <t:inputFileUpload storage="file" value="#{uploadBean.file}"></t:inputFileUpload>
            <h:commandButton value="Submit" action="#{upload.upload}"></h:commandButton>


    5. Finally I put the tomahawk.jar and the commons-file-upload.jar and common-io.jar in the .ear that packages the web application and the EJB's. Of course you need to add the class-path in the MANIFEST.MF of the .ear file.


    Class-Path: jboss-seam.jar commons-fileupload-1.1.jar commons-io-1.2.jar tomahawk.jar


    Hope it helps.


    Marcio Endo




    Ok, so I have attached an example on how to implement file upload with Seam. The file is


    I suck at Ant, so it doesn't contain a nice build.xml. But you CAN generate the necessary .ear by running:


    ant -f packaging-build.xml


    The attached example worked with:


    • JBoss-4.0.4.CR2

    • JBoss-Seam-1.0.0.CR2

    • MyFaces 1.1.1

    • Tomahawk 1.1.1




    Marcio Endo




    There's no need to update the manifest file. I have managed to integrated all of the tomahawk components without touching the manifest. I'll be posting the configuration in a while




    Fady Matar




    Alternative FileUpload


    I have put together a sample File Upload that does not require a backing bean and uses the seam gen tool to create the project.


    Arthur Marinis