Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
Column

From the point of view of the user interface, most web applications can be thought of simply as CRUD (Create, Retrieve, Update & Delete) operations on documents. In the diagram below, the form is being used to initially display a Customer and Order and then to update them. If you think in REST terms, the form is a View Resource that composes multiple Entity Resources (in this case a Customer Resource and an Order Resource), displays their current state and allows you to update them.

Image Modified

Live Forms provides a very flexible and powerful mechanism for interacting with documents (and the web in general). You

...

can download source code and forms

...

 for the discussion below. We strongly recommend that you download the example, study it and use it as a template for integrating with your own web applications.

Column
width240px

On This Page:

Table of Contents
maxLevel1

 

 

 

Document URIs

For each Document Type that you add to your form, Live Forms permits you to assign

...

A document URI template can also be linked to a form control. To do this, use the Control Name. Consider the [[#Updating_a_document|Updating a document]] example  example above and the [http://www.frevvo.com/frevvo/web/user/gallery/app/_73zHwep_EduZgK0BUzi1Ug/formtype/__AKE4PgqEdusGKt5_HoCDw?_method=POST&embed=true&customer=02 sample form] therein sample form therein.

The form has a Customer document and we have specified URI template .../customers/{customer} and Read method GET. In this form, there is a control which has Type ID 'customer' as shown in the figure below.

...

If you enter an ID that does not exist, the GET will fail (return an empty document or a 404 HTTP status code). In this case, frevvo will automatically revert back to the default document with [[V4_Designing_Forms#Setting_a_Default_Value_for_a_Control |default values]] as default values as specified by the designer.

...

This example is a good way to understand Live Forms's handling of document URIs and the powerful capabilities of composing multiple document resources into view resources. You can download the entire example including source code and forms [http://www.frevvo.com/bucket/restlet/RestletCustomerExample.zip by clicking here].

This example follows the principles of REST and uses the [http://www.restlet.org Restlet framework] but  but you can use any framework or server-side model that you like. As mentioned earlier, Live Forms forms can be thought of as View Resources that compose one or more Entity Resources (documents). In this example we have entities Customer and List of Customers. Reproduced here are the methods that they support.

...

The Form action for this form is set to the URI template: http://<hostname>/frevvo/web/user/gallery/app/_73zHwep_EduZgK0BUzi1Ug/formtype/__AKE4PgqEdusGKt5_HoCDw?_method=POST&customer={ID}. As described in the [[#Multi_Multi page _forms|Multi Page Forms]] section aboveforms section, when the user clicks submit, the URI template above will be resolved based on the selected customer ID and the browser will be redirected to the resulting URI, which is simply that of the next form with a query parameter (customer=02, for example). This form is described below.

...

This form is described in the [[#Updating_a_document|Updating a document]] section  section above. It GETs the XML representation for a specific customer using the third method in the table above, initializes the form with that information and displays it to the user. When submitted, the updated customer information is automaticlly PUT to the same [resolved] URI using the fourth method in the table above.

...

This form is described in the [[#Creating_a_new_document|Creating a new document]] section  section above. When instantiated, it does a POST to the Read URI using the second method in the table above. This causes the server to create a new customer and return the URI of that customer. Live Forms will automatically follow this URI, GET the representation of the customer and display the form (presumably with empty values). When the user enters all required fields and submits the form, Live Forms will automatically PUT the resulting XML document to the URI for the newly created customer thereby updating the customer.

...

You can find further discussion of this example on the Live Forms blog blog. The relevant articles are: [http: //www.frevvo.com/blog/?p=26Part 1] and [http://www.frevvo.com/blog/?p=32   and Part 2]. Other articles that may be of interest are [http://www.frevvo.com/blog/?p=23 How do I use my brand new WOA?] and [http://www.frevvo.com/blog/?p=35  and Ajax+REST: the next killer app?].