usege of uploadify in a spring webflow flow -
this first question here please point me right direction if wrong. i'm experiencing difficulties while trying use uploadify flash based multi file uploader inside spring webflow flow. here detailed explanation of case:
here versions of libraries i'm using:
spring-webflow 2.3.2 spring-web 3.2.1 springwebmvc 3.2.1 uploadify v3.2 commons-fileupload 1.2.2 commons-io 2.4 commons-codec 1.8 apache tiles 3.0.1
webflow conf
<webflow:flow-executor id="flowexecutor"> <webflow:flow-execution-listeners> <webflow:listener ref="loggingflowexecutionlistener" /> </webflow:flow-execution-listeners> <!-- max execution sayisina ciktiktan sonra mevcut execution'larin hepsini kill ediyor --> <webflow:flow-execution-repository max-executions="10" /> </webflow:flow-executor> <webflow:flow-registry id="flowregistry" base-path="/web-inf/views" flow-builder-services="flowbuilderservices"> <webflow:flow-location-pattern value="/**/*-flow.xml" /> </webflow:flow-registry> <webflow:flow-builder-services id="flowbuilderservices" view-factory-creator="mvcviewfactorycreator" development="true" /> <bean id="mvcviewfactorycreator" class="org.springframework.webflow.mvc.builder.mvcviewfactorycreator"> <property name="viewresolvers"> <list> <ref bean="tilesviewresolver" /> </list> </property> </bean> <bean id="loggingflowexecutionlistener" class="com.ilanus.demo.web.config.loggingflowexecutionlistener" />
flow definition
<on-start> <evaluate expression="advertisementcreationcontroller.initializeadvertismentform(flowscope.advform)" result="flowscope.advform" /> <evaluate expression="uploadngcontroller.initializeuploadbean()" result="flowscope.uploadbean"></evaluate> </on-start> <view-state id="cadv1" view="cadv1" model="advform"> <transition on="next" to="cadv2"> <evaluate expression="advertisementcreationcontroller.initializecriterias(flowscope.advform)" /> </transition> <transition on="cancel" to="home" /> </view-state> <view-state id="cadv2" view="cadv2" model="advform"> <transition on="previous" to="cadv1" /> <transition on="next" to="cadv3"> <evaluate expression="advertisementcreationcontroller.adjustcheckboxvalues(flowscope.advform, requestparameters)"></evaluate> </transition> <transition on="cancel" to="home" /> </view-state> <view-state id="cadv3" view="cadv3" model="uploadbean"> <transition on="previous" to="cadv2" /> <transition on="next" to="cadv4" /> <transition on="cancel" to="home" /> </view-state>
now, on cadv3 view have uplodify integration. required js, css etc libraries put page , there form:form tag used uploadify upload files. here cadv3.jsp:
<div class="createad2-fileuploadarea"> <form:form modelattribute="uploadbean" method="post" enctype="multipart/form-data"> <input id="file-upload" type="file"/> <input name="dummy" value="somevalue" type="text"> </form:form> <span class="createad2-startupload">yüklemeyi başlat</span> </div>
and here javascript code initialize uploadify:
$('#file-upload').uploadify( { 'swf' : fileuploadscriptbaseurl + '/uploadify.swf', 'uploader' : '/fileupload', 'multi' : true, 'auto' : false, 'cancelimg' : imagebaseurl + '/uploadify-cancel.png', 'buttontext' : 'resim ekle', 'filesizelimit' : '120kb', 'filetypeexts' : '*.gif; *.jpg; *.jpeg; *.png', 'uploadlimit' : 10, . . . });
the controller handing /fileupload url:
@requestmapping(value = "/fileupload", method = requestmethod.post) public @responsebody string uploadcreate(uploadbean uploadbean, bindingresult result, httpservletrequest request, httpservletresponse response, multipartrequest multipartrequest) { system.out.println("started uploading.."); . . . }
and uploadbean:
public class uploadbean implements serializable{ private static final long serialversionuid = -4487086999401144339l; private commonsmultipartfile filedata; private string name; private string dummy; public commonsmultipartfile getfiledata() { return filedata; } public void setfiledata(commonsmultipartfile filedata) { this.filedata = filedata; } public string getname() { return name; } public void setname(string name) { this.name = name; } public string getdummy() { return dummy; } public void setdummy(string dummy) { this.dummy = dummy; }
}
here, problem filedata of uploadbean never gets populated uploadify submits. it's fields null. (dummy field there testing purposes) wrong using flow scoped variable(flowscope.uploadbean) form modelattribute value? or forbidden have ajax submits(uploadify makes ajax calls submit file inputs afaik) inside webflow flow?
by way can use uploadify in spring mvc environment described here: http://springsourcery.org/springsourcery/content/viewcontent,1,32.html?random=4063 i'm doing wrong related spring webflow, helps appreciated, in advance.
solved issue, due multipart configuration, this:
i have implemented webapplicationinitializer interface initialize web application(ie no web.xml), inside implementation there line
dispatcher.setmultipartconfig(new multipartconfigelement(null, max_file_upload_size, max_request_size, file_size_threshold));
this multipartconfigelement(from javax.servlet package) setting size limits, , somehow disturbed spring's file upload mechanism. think it's related to: apache commons fileupload fileitemiterator hasnext() returns false
look @ balusc's comment on second(accepted) answer. anyway, after commenting out above line works expected. hope helps somebody, thanks.
Comments
Post a Comment