The first task in creating a Folder Listing web script is to create the scripted
components.
-
Log in to SkyVault Share:
- Open a web browser and enter the URL: http://localhost:8080/share
- If prompted, log in with the user name admin and password admin.
- Click the Repository link in the Share header.
- Navigate to Data Dictionary > Web Scripts Extensions > org > example.
-
Create a web script description document for the Java Folder Listing example:
- In the Create menu, select XML.
- Enter the name for the web script in the Name field: javadir.get.desc.xml
-
Type the following in the content box:
<webscript> <shortname>Folder Listing Utility</shortname> <description>Java-backed implementation of listing folder contents </description> <url>/javadir/{folderpath}?verbose={verbose?}</url> <authentication>user</authentication> </webscript>
- Click Create.
- Navigate back to the org/example folder using the breadcrumb trail.
-
Create a web script response template for your Java Folder Listing example:
- In the Create menu, select Plain Text.
- Enter the name for the web script in the Name field: javadir.get.html.ftl
-
Type the following in the content box:
<html> <head> <title>Folder ${folder.displayPath}/${folder.name}</title> </head> <body> <p>SkyVault ${server.edition} Edition v${server.version} : dir</p> <p>Contents of folder ${folder.displayPath}/${folder.name}</p> <table> <#list folder.children as child> <tr> <td><#if child.isContainer>d</#if></td> <#if verbose> <td>${child.properties.modifier}</td> <td><#if child.isDocument> ${child.properties.content.size}</#if></td> <td>${child.properties.modified?date}</td> </#if> <td>${child.name}</td> </tr> </#list> </table> </body> </html>
- Click Create.
- Navigate back to the org/example folder using the breadcrumb trail.
The web script description specifies a URI template containing the tokens
{folderpath} and {verbose?}. The
folderpath token represents the folder to list and the
verbose URI argument specifies whether a verbose listing is required or
not. The HTML response template renders the contents of the specified folder, taking into
account the verbose flag. It does this by accessing the web script model
values named folder and verbose.
The web script is not yet complete, as it is still missing its controller. The controller must parse the URI to extract the token values, interact with the repository to locate the specified folder, and populate the model for subsequent rendering by the HTML response template.
Note: It is also possible to create these files as stand-alone files using an external text
editor. Once these files are created you could locate them as follows:
./tomcat/shared/classes/alfresco/extension/templates/webscripts/org/example/javadir.get.desc.xml ./tomcat/shared/classes/alfresco/extension/templates/webscripts/org/example/javadir.get.html.ftl