Page 1 of 1

Javascript events

Posted: Fri Mar 27, 2009 8:15 am
by talal
Hi,

I would like to use JBatchUpload in my ASP.NET web page. For that, I would like to know if there is a way to have events in javascipt in order to detect for example when one file has completed uploading and when the whole batch is done.
For example, I would like to process the files one by one as they are sent. I think this is done by specifying a URL in the parameter url. But then, once all the batch has been completed, I need to perform a special postback to display the results on screen. In fact, it would be like simulating a button click and then in the code-behind, I would handle the event of the click.
My question is basically: can I have a javascript method called when the batch is done?

Thanks,
Talal

Re: Javascript events

Posted: Sat Mar 28, 2009 11:06 am
by support
Answer is Yes with JSAPI:
http://www.jfileupload.com/products/tools/index.html

Install JBatchUpload over JSAPI and you will have the following JavaScript callbacks:

Code: Select all

function JSTransferTriggered(filelist)
{
}

function JSTransferStarted(filename, filesize)
{
}

function JSTransferCompleted(filename)
{
}

function JSTransferCancelled()
{
}

function JSTransferFailed(errormsg)
{
}

function JSTransferDone(filelist)
{
}
Does it help ?

Re: Javascript events

Posted: Mon Mar 30, 2009 12:14 pm
by talal
Yes, I figured it thanks!

I am now trying to integrate the control into one of my pages. I need to add a parameter to the call of the upload URL. How could I do that with the javascript code?
I tried getting rid of the javascript code by inserting directly the object tag and applet tag into the ASPX html code. but as soon as i hit upload, it hangs. nothing happens. I am sure it's because of my transformation of the code because I have used for testing, the page that you provide as an example, except that I replace the script call to the JS page, by the direct declaration.
Why is this an issue? am I missing something?
do you have an example of such a declaration without javascript?

I am using WeakSSL and JSAPI.

The code that I have is the following:

Code: Select all

<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="500" HEIGHT="250" NAME="fileupload" codebase="http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0">
 <PARAM NAME=CODE VALUE="jfileupload.upload.client.JSMApplet.class">
 <PARAM NAME=CODEBASE VALUE="./">
  <PARAM NAME=ARCHIVE VALUE="lib2/jfileupload.jar,lib2/httpimpl.jar,lib2/chttpclient.jar,lib2/clogging.jar,lib2/batchui.jar, lib2/weakssl.jar,lib2/jsapi.jar">
 <PARAM NAME=NAME VALUE="fileupload">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
<PARAM NAME="scriptable" VALUE="true">
<PARAM NAME="url" VALUE="https://server/TestSite/ProcessFile.aspx?mysessionID=<%=Session.SessionID%>">
<PARAM NAME="paramfile" VALUE="uploadfile">
<PARAM NAME="param1" VALUE="todo">
<PARAM NAME="value1" VALUE="upload">
<PARAM NAME="param2" VALUE="errorheader">
<PARAM NAME="value2" VALUE="custommessage">
<PARAM NAME="param3" VALUE="relativefilename">
<PARAM NAME="value3" VALUE="true">
<PARAM NAME="param4" VALUE="weakssl">
<PARAM NAME="value4" VALUE="dummy">
<PARAM NAME="folderdepth" VALUE="0">
<PARAM NAME="maxfiles" VALUE="50">
<PARAM NAME="mode" VALUE="http">
<PARAM NAME="transferui" VALUE="jfileupload.transfer.client.edesign.BatchTransferUI">
<PARAM NAME="transferuiresources" VALUE="i18n_pane">
<PARAM NAME="resources" VALUE="i18n_bar_en-US">
<PARAM NAME="resetprogressbar" VALUE="true">
<APPLET CODE="jfileupload.upload.client.JSMApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib2/jfileupload.jar,lib2/httpimpl.jar,lib2/chttpclient.jar,lib2/clogging.jar,lib2/batchui.jar, lib2/weakssl.jar,lib2/jsapi.jar" WIDTH="600" HEIGHT="250" NAME="fileupload">
<PARAM NAME=CODE VALUE="jfileupload.upload.client.JSMApplet.class">
<PARAM NAME=CODEBASE VALUE="./">
<PARAM NAME=ARCHIVE VALUE="lib2/jfileupload.jar,lib2/httpimpl.jar,lib2/chttpclient.jar,lib2/clogging.jar,lib2/batchui.jar, lib2/weakssl.jar,lib2/jsapi.jar">
<PARAM NAME=NAME VALUE="fileupload">
<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">
<PARAM NAME="scriptable" VALUE="true">
<PARAM NAME="url" VALUE="https://server/TestSite/ProcessFile.aspx?mysessionID=<%=Session.SessionID%>">
<PARAM NAME="paramfile" VALUE="uploadfile">
<PARAM NAME="param1" VALUE="todo">
<PARAM NAME="value1" VALUE="upload">
<PARAM NAME="param2" VALUE="errorheader">
<PARAM NAME="value2" VALUE="custommessage">
<PARAM NAME="param3" VALUE="relativefilename">
<PARAM NAME="value3" VALUE="true">
<PARAM NAME="param4" VALUE="weakssl">
<PARAM NAME="value4" VALUE="dummy">
<PARAM NAME="folderdepth" VALUE="0">
<PARAM NAME="maxfiles" VALUE="50">
<PARAM NAME="mode" VALUE="http">
<PARAM NAME="transferui" VALUE="jfileupload.transfer.client.edesign.BatchTransferUI">
<PARAM NAME="transferuiresources" VALUE="i18n_pane">
<PARAM NAME="resources" VALUE="i18n_bar_en-US">
<PARAM NAME="resetprogressbar" VALUE="true">
</APPLET>
</OBJECT>   
Thanks,
Talal

Re: Javascript events

Posted: Mon Mar 30, 2009 4:08 pm
by talal
Hi again,

I managed to make the javascript work as it is given in the example.

I would like to know how I can modify the buttons (select, start, cancel) I would like to disable the select and start when the user clicks on cancel. So in general, how do we work with the controls in the applet?

Thanks,
Talal

Re: Javascript events

Posted: Mon Mar 30, 2009 4:45 pm
by support
You can customize the UI thanks to i18n_pane.properties and i18n_bar.properties text files. You have a tutorial at:
http://www.jfileupload.com/products/jfi ... ation.html

Is it enough to do what you need ?

Re: Javascript events

Posted: Tue Mar 31, 2009 8:04 am
by talal
Thanks, I was already looking at these files but none of my changes (even small ones, like text change) were not working. I will have a look again at it today maybe it was a problem of cache or something.

I have deployed my website on the test server and I keep getting error 302 after the first upload finishes. I thought it was due to the integration I made of the java control into one of my pages, so I tried using the provided applet_http_aspx.html file, with some modification to user weakssl and jsapi, but still the same problem happens.

Also, we have bought the jfileupload and the jbatchupload. I copied the corresponding jars of each zip file and overwrote the one I was using from the demo project. but I still keep getting "unregistered" in the control. Is there something else I have to do to make this work? we need to release the project onto the client's server and we cannot do so with "unregistered". Weird as it may seem, I am not getting error 302 on the client's server! Only on our test server.
Any quick help is much appreciated.

Thanks,
Talal

Re: Javascript events

Posted: Tue Mar 31, 2009 9:18 am
by talal
Hi again,

I am now able to make the registered jars work without the jsapi. This is what I have done:
I created a new webfolder. I first copied the jfileupload files in int (registered) and tested, it worked fine, the applet appears. I have added the batch upload from the package that we bought yesterday and it also worked. After that, I added weakssl.jar and tried accessing using https, and it worked well. Now, I copied the jsapi.jar and its html and js files into the webfolder and this is the error I get:

java.lang.NoClassDefFoundError: jfileupload/transfer/client/core/N
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.defineClassHelper(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.access$100(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: jfileupload.transfer.client.core.N
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 19 more
Caused by: java.io.IOException: open HTTP connection failed:http://localhost/newjfu/jfileupload/tra ... re/N.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 23 more
Exception: java.lang.NoClassDefFoundError: jfileupload/transfer/client/core/N

I don't get it. The exact same files in unregistered mode are working well in another web folder. I copied those files into the new folder that I created and i got the same error. How can the exact same files produce an error in one folder and no error in another folder?? I have checked the size, it's the same to the byte.

thanks,
Talal
talal wrote:Thanks, I was already looking at these files but none of my changes (even small ones, like text change) were not working. I will have a look again at it today maybe it was a problem of cache or something.

I have deployed my website on the test server and I keep getting error 302 after the first upload finishes. I thought it was due to the integration I made of the java control into one of my pages, so I tried using the provided applet_http_aspx.html file, with some modification to user weakssl and jsapi, but still the same problem happens.

Also, we have bought the jfileupload and the jbatchupload. I copied the corresponding jars of each zip file and overwrote the one I was using from the demo project. but I still keep getting "unregistered" in the control. Is there something else I have to do to make this work? we need to release the project onto the client's server and we cannot do so with "unregistered". Weird as it may seem, I am not getting error 302 on the client's server! Only on our test server.
Any quick help is much appreciated.

Thanks,
Talal

Re: Javascript events

Posted: Tue Mar 31, 2009 7:13 pm
by support
I've sent you the Enterprise version of JSAPI, it should work now.

Re: Javascript events

Posted: Tue May 26, 2009 5:51 pm
by inspireuk
i am having a simular issue - the red unregistered message has gone but the blue one remains - is this due to the jsapi?
thanks,
Josh

Re: Javascript events

Posted: Wed May 27, 2009 6:16 am
by support
No, it's not because of JSAPI. Which license do you have ? Pro ? Do you have one license for each product ?