This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JSF and the fly likes upload file using jsf 2.0 and tomahawk Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "upload file using jsf 2.0 and tomahawk" Watch "upload file using jsf 2.0 and tomahawk" New topic
Author

upload file using jsf 2.0 and tomahawk

alisha agarwal
Greenhorn

Joined: Sep 19, 2013
Posts: 4
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

Joined: Jun 25, 2001
Posts: 17039
    
  26

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.


An IDE is no substitute for an Intelligent Developer.
alisha agarwal
Greenhorn

Joined: Sep 19, 2013
Posts: 4
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

Joined: Sep 19, 2013
Posts: 4
I am showing you my bean class also .

alisha agarwal
Greenhorn

Joined: Sep 19, 2013
Posts: 4
And I have one hbm file corresponding to the above bean and one DAO class also.
 
Have you checked out Aspose?
 
subject: upload file using jsf 2.0 and tomahawk
 
jQuery in Action, 3rd edition