Handling form data
The rating example makes an AJAX call using the POST method. What if, instead of using AJAX, you were simply posting an HTML form? The web script framework is able to handle form posts, including multi-part forms.
For example, let's implement a new HelloWorld example as a form post instead of passing the name argument in the query string. We can use a static HTML
page to render the form, but for the cost of an extra descriptor let's use a web script for both the GET
(to render the form) and the POST
(to process the form data). To do this, you'll need two descriptors (one for GET
and one for POST
), two FreeMarker templates, and a JavaScript controller.
Step-by-step - implementing a form-based Hello World
To create a new version of the Hello World web script using a form, do the following:
Create a descriptor for the
GET
calledhelloworldform.get.desc.xml
inrepo
|src
|main
|amp
|config
|alfresco
|extension
|templates
|webscripts
|com
|someco
with the following content...