multiplefileupload.lzx
<library>
<include href="fileuploadlist.lzx"/>
<class name="multiplefileupload">
<simplelayout axis="y"/>
<attribute name="numfields" value="1
"/>
<attribute name="erroroccured" type="boolean" value="false
"/>
<handler name="oninit">
for(var i=0;i<numfields;i++){
var t = new lz['fileuploadlist'](content);
}
</handler>
<method name="addField">
this.setNumFields(numfields+1);
</method>
<method name="removeField">
this.setNumFields(numfields-1);
</method>
<method name="checkError">
this.setAttribute('erroroccured', false);
for(var i=0; i<this.content.subnodes.length;i++ ){
if(this.content.subnodes[i] instanceof lz.fileuploadlist){
if(this.content.subnodes[i].erroroccured ==true){
this.setAttribute('erroroccured', true);
}
}
}
return(this.erroroccured);
</method>
<method name="setNumFields" args="num">
if(num>0)
if(num > numfields){
for(var i=numfields;i<num;i++){
var t = new lz['fileuploadlist'](content);
}
this.setAttribute('numfields',num);
}else if(num < numfields){
var count= numfields - num;
var kill = 0;
for(var i=numfields-1;i>=0;i--){
if(content.subviews[i].selected==false){
content.subviews[i].destroy();
kill++;
}
}
if(kill>count){
for(var i=0;i<kill-count;i++){
var t = new lz['fileuploadlist'](content);
}
}else if(kill < count){
for(var i=numfields-kill-1;i>=numfields-count;i--){
content.subviews[i].destroy();
}
}
this.setAttribute('numfields',num);
}
</method>
<method name="clearAllFields">
for(var i=0; i<numfields;i++){
content.subviews[i].remove.onclick.sendEvent();
}
</method>
<simplelayout axis="y" spacing="5"/>
<view name="content">
<simplelayout axis="y" spacing="5"/>
</view>
<button name="upload" text="Upload" x="410" enabled="true">
<handler name="onclick">
for(var i=0; i<parent.content.subnodes.length;i++){
if(parent.content.subnodes[i] instanceof lz.fileuploadlist && parent.content.subnodes[i].selected==true){
parent.content.subnodes[i].myFileUpload.upload('upload.jsp');
}
}
</handler>
</button>
<doc>
<tag name="shortdesc"><text>A swf-specific class for uploading multiple files to a server</text></tag>
<text>
<p>
A class for uploading a single file using the Flash file upload api. This only works with
the swf runtime, that is, with lzr=swf10.
</p>
<p>
Using this class requires a service to which to upload. A sample upload jsp is provided,
which uses the cos.jar library from servlets.com. To use the example, copy cos.jar from
<a href="http://www.servlets.com/cos/index.html">servlets.com</a> into $TOMCAT_HOME/common/lib
and rename lps/components/incubator/uploader/example/upload.jsp.txt to upload.jsp.
Restart tomcat, so it will see the new jar, then visit
<a href="http://localhost:8080/legals/lps/components/incubator/uploader/example/test-multiplefileupload.lzx?lzr=swf10">
http://localhost:8080/legals/lps/components/incubator/uploader/example/test-multiplefileupload.lzx?lzr=swf10</a>
</p>
<p>(The terms of the servlets.com license forbid it from being redistributed
with OpenLaszlo.)
</p>
<p>
To upload a single file, see <tagname>fileupload</tagname>.
</p>
</text>
</doc>
</class>
</library>
Cross References
Includes
Classes