Book Image

Alfresco Developer Guide

Book Image

Alfresco Developer Guide

Overview of this book

Table of Contents (17 chapters)
Alfresco Developer Guide
Credits
About the Author
About the Reviewers
Preface
Index

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 re-do the 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 convert the Hello World web script to use a form, do the following:

  1. Create a descriptor for the GET called helloworldform.get.desc.xml in |config|alfresco|extension|templates|webscripts|com|someco with the following content:

    <webscript>
      <shortname>Hello World Form&lt...