-
1. Re: Uploading Excel sheet in data base using seam
mdesignz Jun 1, 2009 3:40 PM (in response to gauravsinghc)It would help if you could post how you're currently trying to do this. Are you using s:fileUpload or something else?
-
2. Re: Uploading Excel sheet in data base using seam
gauravsinghc Jun 2, 2009 7:42 AM (in response to gauravsinghc)//this is my xhtml page which i am using for upload
//XHTML
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
xmlns:a="https://ajax4jsf.dev.java.net/ajax">
<rich:simpleTogglePanel switchType="client"
label="Upload">
<h:panelGrid width="75%">
<h:panelGroup id="Upload">
<h:form enctype="multipart/form-data">
<table border="0">
<tbody>
<tr>
<th>
<h:outputText value="UploadExcel :" />
</th>
<th>
<s:fileUpload data="${massDataUploadService.data}"
accept="${massDataUploadService.accept}"
contentType="${massDataUploadService.contentType}"
fileName="${massDataUploadService.name}"
fileSize="${massDataUploadService.size}" size="40"
maxlength="80" />
</th>
</tr>
<tr>
<td>
</td>
<td>
<a:commandButton value="Upload" action="#{massDataUploadService.upload}"/>
<rich:spacer width="10" />
<a:commandButton value="Cancel" type="reset"/>
</td>
</tr>
</tbody>
</table>
</h:form>
</h:panelGroup>
</h:panelGrid>
</rich:simpleTogglePanel>
</ui:composition> -
3. Re: Uploading Excel sheet in data base using seam
gauravsinghc Jun 2, 2009 7:46 AM (in response to gauravsinghc)// I am just trying print the values i am getting
// but i am getting all the values as null
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.log.Log;
@Scope(ScopeType.SESSION)
@Name("massDataUploadService")
public class MassDataUploadAction {
@Logger
Log log;
private static final String accept = "text/plain,text/xml,application/xml,application/vnd.ms-excel";
private byte[] data;
private String contentType;
private String name;
private String title;
private int size;
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String getContentType() {
return contentType;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getSize() {
return size;
}
public void setSize(int size) {
this.size = size;
}
public void upload(){
System.out.println("in upload---name----> "+name);
System.out.println("in upload---contentType----> "+contentType);
System.out.println("in upload---size----> "+size);
System.out.println("in upload---title----> "+title);
}
public String getAccept() {
return accept;
}
} -
4. Re: Uploading Excel sheet in data base using seam
gauravsinghc Jun 2, 2009 7:49 AM (in response to gauravsinghc)// components.xml
<component class="org.jboss.seam.web.MultipartFilter">
<property name="createTempFiles">true</property>
<property name="maxRequestSize">1000000</property>
</component>
// web.xml
<filter>
<filter-name>Seam Filter</filter-name>
<filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Seam Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> -
5. Re: Uploading Excel sheet in data base using seam
mdesignz Jun 2, 2009 3:59 PM (in response to gauravsinghc)The syntax for s:fileUpload looks correct. I've never tried embedding it within a table, but I noticed that you have:
xmlns:rich="http://richfaces.ajax4jsf.org/richIn my stuff that works just fine, I have:
xmlns:rich="http://richfaces.org/rich"Version of Seam / Richfaces you're using?
-
6. Re: Uploading Excel sheet in data base using seam
gauravsinghc Jun 3, 2009 5:55 AM (in response to gauravsinghc)hey Robert thanks for your quick reply..
it tried it and even removed the table but still it didnt work for me
still every thing is comming nullmy seam version is 2.1.0
can you please post your code
and also do i need any specific jar for uploading -
7. Re: Uploading Excel sheet in data base using seam
gauravsinghc Jun 3, 2009 1:12 PM (in response to gauravsinghc)Seam Version is Seam 2.1.0.SP1
RichFaces version is 3.2.2.GA -
8. Re: Uploading Excel sheet in data base using seam
mdesignz Jun 3, 2009 3:49 PM (in response to gauravsinghc)You're sure that the jboss-seam-pdf.jar file is in the correct place? In my EAR deployment, I have it in the war (WEB-INF/lib).
-
9. Re: Uploading Excel sheet in data base using seam
mdesignz Jun 3, 2009 5:35 PM (in response to gauravsinghc)Ignore my last comment. I was thinking of a different thread.
-
10. Re: Uploading Excel sheet in data base using seam
mdesignz Jun 3, 2009 5:48 PM (in response to gauravsinghc)Here's an example of what I use to upload an image file. Uploading something like Excel is identical.
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:a="https://ajax4jsf.dev.java.net/ajax" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich">
<h:form styleClass="imageUploadForm" enctype="multipart/form-data"> <a:region> <s:decorate id="imageUploadDecoration" template="includes/formFieldDecorate.xhtml"> <ui:define name="label">Image</ui:define> <s:fileUpload id="imageUpload" fileName="#{image.fileName}" data="#{image.content}" contentType="#{image.contentType}" acceptedTypes="jpg,png,tif" size="80" tabindex="10" required="true" /> </s:decorate> </a:region>
image is managed via EntityHome, and it has simple getters / setters for the properties. And that's it. Works for any kind of file.
-
11. Re: Uploading Excel sheet in data base using seam
gauravsinghc Jun 4, 2009 2:46 PM (in response to gauravsinghc)No results
i am still getting the same null values.
i had even tried to use rich faces to upload file but there also
i am getting all tha values as null
not able to figure out why i am not able to upload file and the whole world can upload the same...:(