0

I want to upload an Excel file to a JBoss Server with JSF, so I used Tomahawk.

Here is the view:

<%@ taglib uri="http://myfaces.apache.org/extensions" prefix="x"%>

<h:form id="MF" enctype="multipart/form-data" >
    <x:inputFileUpload id="fileupload" value="#{dataentryctl.minvoice}" storage="file" required="false" />
    <h:commandButton id="Submit" type="button" action="#{invoiceentryctl.PersistData}" value="save" 
        onclick="revalidateF12();submitForm()" onkeydown="keyDownEvents(this)" />
</h:form>

Here is the controller/model:

package panaceaFACweb.FACCtlbean;

import org.apache.myfaces.custom.fileupload.UploadedFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class dataentryctl {

    private UploadedFile minvoice;

    public UploadedFile getMinvoice() {
        return minvoice;
    }

    public void setMinvoice(UploadedFile minvoice) {
        this.minvoice = minvoice;
    }

    public String PersistData() {
        load();
        return null;
    }

    public void load() {
        ParseXLS parseXls = new ParseXLS();
        try {
            InputStream input = minvoice.getInputStream();          
            // ...
        } catch (IOException e) {           
            e.printStackTrace();
        }catch (Exception e) {          
            e.printStackTrace();
        }
    }
}

I have the following JARs:

  • tomahawk-1.1.9.jar
  • commons-el-1.0.jar
  • commons-logging-1.1.1.jar
  • commons-fileupload-1.2.2-javadoc.jar
  • commons-io-1.4.jar

Other JARs related to JSF are already there. Other JSP pages work fine.

I am getting a NullPointerException on the line InputStream input = minvoice.getInputStream();.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Uthay
  • 505
  • 1
  • 4
  • 7
  • 2
    Format your code in a code block. – Mukul Goel Nov 08 '12 at 12:00
  • Why are you using MyFaces extensions taglib instead of Tomahawk taglib? Replace `http://myfaces.apache.org/extensions` by `http://myfaces.apache.org/tomahawk` and `` by ``, just to be sure. What exactly are those JS onclick/onkeydown functions on the submit button doing? Remove them and retry, just to be sure that they didn't do wrong stuff. Do you have MyFaces extensions filter configured in `web.xml`? – BalusC Nov 08 '12 at 12:31
  • Yes Mr Mukul , I had changed to http://myfaces.apache.org/tomahawk and . Now I am getting "http://myfaces.apache.org/tomahawk" Not found. Error :(. I had Added the Jar and i had also Configured web.xml . – Uthay Nov 15 '12 at 12:09
  • MY WEB.xml Changes. extensionsFilter org.apache.myfaces.webapp.filter.ExtensionsFilter ... uploadMaxFileSize 100m ... uploadThresholdSize 100k extensionsFilter*.jsf – Uthay Nov 15 '12 at 12:17
  • extensionsFilter/faces/* – Uthay Nov 15 '12 at 12:18

0 Answers0