Response status code templates allow a web script to render a custom response for a
given status code. This is useful for providing unique information about a status code or to
render a custom human readable interface. Your Folder Listing web script returns a 404 (Not
Found) status code if the requested folder to list does not exist in the content repository. By
default, the web script responds with a generic response that provides details about the status
including its descriptive message. This is useful for diagnosis but may not be consumable by the
typical user of the web script. You can add a custom response status code template
that renders a human readable message when the folder cannot be found.
-
Log in to SkyVault Explorer:
- In your browser, enter: http://localhost:8080/SkyVault
- If prompted, log in with the user name admin and password admin.
- Navigate to Company Home > Data Dictionary > Web Scripts Extensions > org > example.
-
Create the response status code template:
- In the Create menu, click Create Content.
- Enter the name for the web script in the Name field as follows: dir.get.html.404.ftl
- In the Content Type list, select Plain Text.
- Click Next.
-
Type the following in the Enter Content box:
<html> <body> <p>SkyVault ${server.edition} Edition v${server.version} : dir</p> <p>Folder <b>${url.templateArgs.folderpath}</b> not found.</p> </body> </html>
- Click Next.
- Click Finish.
-
Register the web script again:
- In your browser, enter: http://localhost:8080/alfresco/service/index
- If prompted, log in with the user name admin and password admin.
-
Test your response code template:
-
Type the following in your web browser:
http://localhost:8080/alfresco/service/dir/doesnotexist
- If you see the custom message, your response status code template is working.
As with all web script component files, response status code template file names adhere to a naming convention as defined by the Web Script Framework.
-
Type the following in your web browser:
Response status code templates have access to the same root objects as normal web script
response templates except the default templates <code>.ftl and
status.ftl only have access to the root objects url,
status, server, and date.
When
developing web scripts, leave the implementation of response status code templates until the
end as they are not essential to their execution. You can test without custom response status
code templates, as the Web Script Framework will always eventually find the default template
status.ftl in the root package.
As with all other response templates,
adding and removing a response status code template requires you to re-register the web
script.