Difference between revisions of "DownloadList"

From HSYCO
Jump to navigation Jump to search
(Created page with "{{UI Object Header}} A panel with a list of items that work like download buttons, used to execute a download callback (a customized Java code or an event for the...")
 
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{UI Object Header}}
 
{{UI Object Header}}
A panel with a list of items that work like [[download|download buttons]], used to execute a download callback (a customized Java code or an event for the EVENTS interpreter).
+
A panel with a list of items that work like the [[download (UI Object)|download button]], used to download a file from the HSYCO Server to the local storage of the user's client device.
 +
:[[File:UI Object downloadlist.png]]
  
Pressing an item of the list, HSYCO calls the method:
+
For security reasons, in order to select the file to be downloaded, a server-side userCommand callback is called when a list item is pressed, receiving the object's id and item's value as parameters, and must return the pathname of the file to be downloaded, relative to HSYCO's main directory.
:userCommand(String name, String param)
+
 
in the user.class class. HSYCO also executes all actions associated to the event:
+
Only if the returned pathname is a valid file under the HSYCO main directory, the file will be actually served to the client for download.
:USER name=param
+
 
defined in EVENTS.
+
The value parameter can be set to any string value, that should be interpreted by the server-side userCommand code to set the pathname for download, if authorised.
 +
 
 +
Because of the way it is implemented, the downloadlist object can only be used with server code written in JavaScript or Java.
 +
 
 +
If the application being developed has no strong security implications, a simple JavaScript callback code like this, or its Java equivalent, would allow serving any file by specifying a list of pathnames in the values parameter of the downloadlist object:
 +
 
 +
function userCommand(session, userid, name, param) : {
 +
    if (name == "download") {
 +
        return param;
 +
    }
 +
}
  
[[File:UI Object downloadlist.png]]
 
  
 
== Parameters ==
 
== Parameters ==

Latest revision as of 13:42, 4 March 2017

Note  For a description and a complete list of UI Objects, see UI Objects.

A panel with a list of items that work like the download button, used to download a file from the HSYCO Server to the local storage of the user's client device.

UI Object downloadlist.png

For security reasons, in order to select the file to be downloaded, a server-side userCommand callback is called when a list item is pressed, receiving the object's id and item's value as parameters, and must return the pathname of the file to be downloaded, relative to HSYCO's main directory.

Only if the returned pathname is a valid file under the HSYCO main directory, the file will be actually served to the client for download.

The value parameter can be set to any string value, that should be interpreted by the server-side userCommand code to set the pathname for download, if authorised.

Because of the way it is implemented, the downloadlist object can only be used with server code written in JavaScript or Java.

If the application being developed has no strong security implications, a simple JavaScript callback code like this, or its Java equivalent, would allow serving any file by specifying a list of pathnames in the values parameter of the downloadlist object:

function userCommand(session, userid, name, param) : {
    if (name == "download") {
        return param;
    }
}


Parameters

  • id: the object's ID, used by UISets
  • values: comma-separated list of the values passed to the Java callback method and event in EVENTS
  • labels: comma-separated list of labels corresponding to the parameters. If missing, parameters will be shown instead
  • position: the object's position. Use the pixels or rows and columns coordinates format
  • size: the panel's width and height
  • css: optional. Defines the CSS style for the input field
  • template: optional, html template to be used for each item

Syntax

(downloadlist!<id> <values>; <labels>; <position>; <width>; <height>; <css>; <template>)

E.g.

(downloadlist!mydownloadlist f1,f2,f3; file one,file two,file three; r1c1; 220; 224; font-size:16px)

Template

The template is HTML code that is applied to every item. An item's label is split into parts using the pipe character. These parts are replaced inside the template's code to form the final item's source.

%<n> (with n starting from 1) is used to include each part of the item's label inside the HTML. To avoid the % symbol to be replaced, use &#37; instead.

E.g. If the template is:

<table><tr><td>%1</td><td>%2</td></table>

and the labels are:

a|one,b|two

the resulting items will have the following html code:

<table><tr><td>a</td><td>one</td></table>

and

<table><tr><td>b</td><td>two</td></table>

UI Attributes

Common attributes

Name Value Description
pos x<x>y<y> Position specified as x/y coordinates. E.g. x-5y10
visible true Default. Show the object
false Hide the object
blink true | slow Blink the object at a slow speed
fast Blink the object at a fast speed
false Stop the blinking
opacity 0.0 ... 1.0 Object opacity from 0 (not visible) to 1 (fully visible)
rotation 0 ... 360 Object rotation in degrees. Images are rotated around the center point, all other objects are rotated around the top left corner

DownloadList attributes

Name Value Description
enabled true Object is enabled
false Object is disabled
focus true Focus the object. Only a single object should have this attribute at "true".
false Reset focus
error true Manually shows an error feedback on the panel.
false Hides the error visualization.
values comma-separated list of strings Values
labels comma-separated list of strings UserList labels
width number of pixels Set the object's width
height number of pixels Set the object's height
panel true Show background panel
false Hide background panel
template html code Set the item's template