16) Add an Upload Timer. |
To add an Upload Timer to your application follow three simple steps.
1. Add the XloadUploadTimer folder (located in the root folder after decompressing) to each web application that requires an Upload Timer.
2. Import the javascript file Xload.js (inside the XloadUploadTimer folder from step 1) into the html page that will open an upload timer window.
3. Call the javascript function useProgressWindow(form, contextPath) at some point in your code to invoke the Upload Timer window.
For example if you have a Web Application located at C:\WebApp (Windows™ specific).
1. Add the downloaded XloadUploadTimer folder directly to the WebApp directory. The upload timer is implemented by a JSP file (XloadProgress.jsp) located in the XloadUploadTimer folder. Please make sure that the path to this JSP file is included in any redirects to the JSP Container OR that *.jsp is included in the list of redirects. How you set this up depends upon your Web-Server and/or JSP Container choice.
2. Import the Xload.js javascript file (located inside the XloadUploadTimer folder)into the html page that will open an upload timer, by using something similar to the following inside the header section:
<script language="JavaScript" type="text/JavaScript" src="/context/XloadUploadTimer/Xload.js"> </script>
|
where:
context - is the context path to your application (this can be dynamically set by use of the <c:url value="/"/> tag from the JSTL if you are using a JSP). This can also be set by using relative paths (e.g. ../XloadUploadTimer/Xload.js) but this depends upon your application and its structure.
3. When submitting the form call the useProgressWindow(form, contextPath) by using the following html code:
<form name="F1" enctype="multipart/form-data" action="/context/myservlet" onsubmit="return useProgressWindow(this, '/context')" method="post">
|
IMPORTANT:- You can use the useProgressWindow() function wherever you want in your code as long as you provide it with the correct parameters, for example you could validate user input before calling this method so that a timer window didn’t open prematurely, as the code below shows: |
<script language="JavaScript" type="text/JavaScript"> function validateAndOpenUploadTimer(){ var form = document.F1; ... ... ... //validate user input ... ... ... if(userInputOK){ useProgressWindow(form, 'context'); } } </script>
|
where:
context - is the context path to your application (this can be dynamically set by use of the <c:url value="/"/> tag from the JSTL if you are using a JSP). If there is no context (i.e. lies on the ROOT) then you can just use a forward slash - /.
F1 - is the name of your form.
Definition of Function useProgressWindow():
Function useProgressWindow(form, contextPath)
Opens a progress window if there are files to attempt to upload.
Params - form - The form that is being submitted. contextPath - The context path of the application (e.g. "/context" or "/" if on the ROOT);
Return - Returns true if there are files to attempt to upload, false otherwise.
|
© Gubutech(Xload) 2006 (v1.2)