[ 1 post ]

Bhuvana Pathsamatla

  • Username: Bhuvana
  • Joined: Mon Jun 18, 2012 2:09 am
  • Posts: 15
  • Location: India
  • IRC: Bhuvana
  • Offline
  • Profile
Tags:

Example for uploader with Struts 2 backend

Post Posted: Tue Jul 10, 2012 10:32 pm
+0-
I created a File Uploader using the following code. My backend uses Struts2 . I am using the following code to upload but my Struts action is not getting invoked. For convenince I only pasted important pieces of the code.Can someone help me with this.Also how do we return the progress from the backend?

YUI({filter:"raw"}).use("uploader", function(Y) {
//Y.one("#overallProgress").set("text", "Uploader type: " + Y.Uploader.TYPE);
if (Y.Uploader.TYPE != "none" && !Y.UA.ios) {
var uploader = new Y.Uploader({width: "250px",
height: "35px",
multipleFiles: true,
swfURL: "http://yui.yahooapis.com/3.5.1/build/uploader/assets/flashuploader.swf?t=" + Math.random(),
simLimit: 2
});
var uploadDone = false;

uploader.render("#selectFilesButtonContainer");

uploader.after("fileselect", function (event) {

var fileList = event.fileList;
var fileTable = Y.one("#filenames tbody");
if (fileList.length > 0 && Y.one("#nofiles")) {
Y.one("#nofiles").remove();
}

if (uploadDone) {
uploadDone = false;
fileTable.setHTML("");
}

Y.each(fileList, function (fileInstance) {
fileTable.append("<tr id='" + fileInstance.get("id") + "_row" + "'>" +
"<td class='filename'>" + fileInstance.get("name") + "</td>" +
"<td class='filesize'>" + fileInstance.get("size") + "</td>" +
"<td class='percentdone'>Hasn't started yet</td>");
});
});

Y.one("#uploadFilesButton").on("click", function () {
if (!uploadDone && uploader.get("fileList").length > 0) {
uploader.uploadAll("http://localhost:8080/YUITest/uploadNominationDocs");

}
});
}
else {
Y.one("#uploaderContainer").set("text", "We are sorry, but the uploader technology is not supported" +
" on this platform.");
}


});

</script>
  [ 1 post ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum