File Uploading <s:fileUpload>, data always comes null or 0 length
ambrish_kumar Nov 5, 2009 1:01 PMHi Everyone,
I am uploading a image file using <s:fileUpload> ,but after submitting the form. I get the data value as Null or of 0 length.
Here is my file uploading code :
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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="http://richfaces.org/a4j"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:rich="http://richfaces.org/rich"
template="layout/template.xhtml">
<ui:define name="body">
<h:form id="editCatAttribValForm" enctype="multipart/form-data">
<c:forEach items="#{categoryForProduct}" var="category">
<rich:panel header="#{category.categoryName}">
<h:panelGrid columns="2" border="0">
<c:forEach items="#{attributesMap.get(category.categoryName)}" var="categoryAttrib">
<s:decorate template="layout/edit.xhtml">
<ui:define name="label">#{categoryAttrib.categoryAttributeName} :</ui:define>
<h:inputText size="20"
maxlength="60"
required="true"
rendered="#{categoryAttrib.categoryAttributeType == 'textbox'}"
requiredMessage="Value is required"
value="#{categoryAttrib.tempAttributeValue}">
</h:inputText>
<h:inputTextarea cols="20" rows="5"
required="true"
rendered="#{categoryAttrib.categoryAttributeType == 'textarea'}"
requiredMessage="Value is required"
value="#{categoryAttrib.tempAttributeValue}">
</h:inputTextarea>
<s:fileUpload contentType="#{manageProduct.contentType}"
data="#{manageProduct.fileData}"
fileName="#{manageProduct.fileName}"
rendered="#{categoryAttrib.categoryAttributeType == 'imageupload'}"/>
</s:decorate>
</c:forEach>
</h:panelGrid>
</rich:panel>
</c:forEach>
<div style="clear:both">
<span class="required">*Required fields</span>
</div>
<rich:spacer height="30"></rich:spacer>
<h:commandButton id="updateCatAttrib"
value="Update"
action="#{manageProduct.editAttributeValue}" style="cursor:hand;cursor:pointer;">
</h:commandButton>
<s:button id="cancelAttrib"
value="Cancel"
action="#{manageProduct.cancel}" style="cursor:hand;cursor:pointer;">
</s:button>
</h:form>
</ui:define>
</ui:composition>My command buttons are outside the rich panel. Is this an issue because the same file uploading code is working where command buttons are inside the panel?.
Thanks & Regards
Ambrish