File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

upload file using jsf 2.0 and tomahawk

 
alisha agarwal
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to upload a file using tomahawk20-1.1.10 in jsf2.0 and hibernate. My browse button is working fine. But UploadFile variable is always set to null and hence the data in my database table is not created.Kindly help me as i am stuck on this problem very badly.

here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>

</filter-mapping>





here is my xhtml form

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:t="http://myfaces.apache.org/tomahawk" >

<t:inputFileUpload id="tAttachment" value="#{ScanProposal.uploadFile}" required="true" />
<h:message for="tAttachment" styleClass="LblError"/>




here is my ScanProposal CLASS
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17622
39
Android Eclipse IDE Linux
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Alisha!

You can use the Code tags to wrap XML as well as Java Code. It makes your XML more readable.

The sample code you provided doesn't seem to have its post-upload logic contained within a method. So it would be executed as a construction snippet before the bean was fully populated rather than after the bean had been constructed, initialized, and the upload itself had been done.
 
alisha agarwal
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanxs for your reply. But i am new to jsf as well as hibernate.So it would be very nice if you can elaborate the answer so that i can understand it.
Waiting for your reply.
 
alisha agarwal
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am showing you my bean class also .

 
alisha agarwal
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I have one hbm file corresponding to the above bean and one DAO class also.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic