JavaPowUpload 1.0 control documentation

How to use JavaPowUpload.

This section describe how to use JavaPowUpload applet.

1. How to include JavaPowUpload applet on page

2. How to setup parameters

3. How to specify files for downloading

4. How to use JavaPowUpload events and methods

 

1. How to include JavaPowUpload applet on page:

<applet
code="com.elementit.JavaPowUpload.Manager"
archive="lib/JavaPowUpload.jar, lib/skinlf.jar,
lib/commons-logging-1.1.jar,
lib/commons-httpclient-3.1-rc1.jar,
lib/commons-codec-1.3.jar"
width="600"
height="400"
name="JavaPowUpload"
id="JavaPowUpload"
mayscript="true"
alt="JavaPowUpload by www.element-it.com">

<!-- Java Plug-In Options -->
<param name="progressbar" value="true">
<param name="boxmessage" value="Loading JavaPowUpload Applet ...">
<!-- JavaPowUpload parameters -->
<param name="Common.UploadMode" value="true">
<param name="Upload.UploadUrl" value="FileProcessingScripts/ASP.NET/CSharp/uploadfiles.aspx">
<param name="Common.SkinLF.ThemepackURL" value="lib/themepack.zip">
Your browser does not support applets. Or you have disabled applets in your options.
To use this applet, please install the newest version of Sun's java.
You can get it from <a href="http://www.java.com/">java.com</a>
</applet>

applet

The Applet tag tells the browser that a Java-Applet should be embedded here. The attributes have all required information for Java to find and run the specified Applet from the given archive.

name, id

The name and id of the Applet, that JavaScript is using to access JavaPowUpload.

code

The code tag specifies the location and name of the main class, com.elementit.JavaPowUpload.Manager for javaPowUpload.

archive

The archives contain the applet and further classes that are required by JavaPowUpload.
Note: if only download functionality of JavaPowUpload is used, following archives can be ommited:
lib/commons-logging-1.1.jar
lib/commons-httpclient-3.1-rc1.jar
lib/commons-codec-1.3.ja
Also if skin support not needed, lib/skinlf.jar can be ommited.

width, height

These two attributes specify the dimension (size) of the JavaPowUpload applet.

mayscript

This toggles wether or not JavaScript is allowed to call methods of the JavaPowUpload applet. If this attribute is ommited, JavaScript events and functions will not work.

param

The <param> tags can be used to configure the JavaPowUPload applet. All supported parameters are described in the parameters section. Names and values must be quoted. Also note that the names and values are case-sensitive.

2. How to setup parameters

Parameters can be specified using 3 ways:

1. Using <param> tag of the <applet> tag.

2. Using external xml file, specified with Common.PropertiesFile parameter in <applet> tag.

Example of properties.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="Common.UploadMode">true</entry>
<entry key="Common.BackgroundColor">#FFFFFF</entry>
<entry key="Common.UseLiveConnect">true</entry>
</properties>

3. Using JavaScript setParam method.

Example:

JavaPowUpload.setParam("Upload.UploadUrl","http://localhost/JavaPowUpload/uploadfiles.php");

Parameters specified using setParam method have highest priority, specified in <applet> tag have lowest priority.

3. How to specify files for downloading

There is 2 ways:

1. Xml file with file structure for download, specified with Download.DataURL parameter.

Example:

<?xml version="1.0" encoding="UTF-8"?>
<download>
<folder name="Folder">
<folder name="SubFolder">
<file name="Simplefile.txt" id="1" length="1240">
<url>SampleFiles/textfile.txt</url>
</file>
<file name="SimpleArchive.zip" id="2" length="488">
<url>SampleFiles/archive.zip</url>
</file>
</folder>
<file name="UncompressArchive.zip" id="3" length="488" uncompress="true" delete="true">
<url>SampleFiles/archive.zip</url>
</file>
</folder>
</download>

As you can see in this example, there is the root element download.
You can add folders via the folder element. The attribute name specifies the name of the folder,
which will be created on th eclient side.Folders can have nested subfolders.
Downloadable items are specified by the file element, which also has an attribute name for spe-
cifying the filename on the client side.

Files can have a following attributes:
length - file size.
id - custom identifier.
uncompress - determines whether JavaPowUpload should uncompress zip archive after downloading or not.
delete - determines whether JavaPowUpload should delete zip archive after unpacking or not.

Files cannot have any children elements like file or folder, but they do have a source address.
The source URL of the file to download is specified via an url element.
The url element specifies an absolute URL to the file, but might also be relative to the codebase
URL. The codebase URL is the URL where the applet is loaded from.
If, for example, the JavaPowUpload component is installed to
http://www.example.com/downloads/JavaPowUpload.jar
the codebase URL is
http://www.example.com/downloads/

2. Specify file structure for download via parameters.

Example:

<param name="Folder_0" value="Test folder">
<param name="File_0" value="Textfile.txt">
<param name="File_0.url" value=SampleFiles/textfile.txt">
<param name="File_0.parent" value="Folder_0">
<param name="File_0.length" value="1240">
<param name="File_1" value="SampleArchive">
<param name="File_1.url" value="SampleFiles/archive.zip">
<param name="File_1.parent" value="Folder_0">
<param name="File_1.length" value="488">
<param name="File_1.uncompress" value="true">
<param name="File_1.delete" value="false”>

Format of names: <FILE || FOLDER>_<INDEX>.<ATTRIBUTE> .

Attributes for files and folders are the same as in xml file, except following:
file and folder names should be specified directly in value attribute of corresponding <param> tag,
parent attribute should be specified for all nested files or folders, otherwise they will be added to the root of tree.

4. How to use JavaPowUpload events and methods

1. You should set mayscript attribute for <applet> tag.

2. Set JavaPowUpload parameter Common.UseLiveConnect to true (false by default) .

3. Set JavaPowUpload parameter Common.JavaScriptEventsPrefix to needed value ("JavaPowUpload_" by default) .

To use javaPowUpload events you should declare appropriate JavaScript functions. Function name format is Common.JavaScriptEventsPrefix+eventName. List of all available JavaPowUpload events available in events section.

Example:

function JavaPowUpload_onDownloadStart()
{
 alert("Starting download process");
}

To use JavaPowUpload methods, yo should init JavaPowUpload object.

Example:
//init JavaPowUpload JavaScript object
Java = document.getElementById("JavaPowUpload");
//where "javaPowUpload" is id attribute of <applet> tag>
//Now we can use javaPowUpload methods, for example show browse dialog
Java.clickBrowse();