...
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:Compose_Documents.jpg]]
frevvo provides a very flexible and powerful mechanism for interacting with documents (and the web in general). You can [http://www.frevvo.com/bucket/restlet/RestletCustomerExample.zip download source code and forms] for the discussion below. We '''strongly recommend''' that you download the example, [[#Customer_Example|study it]] and use it as a template for integrating with your own web applications.
==== Document URIs
==== For each [[V4_Designing_Forms#From_Schema|Document Type]] that you add to your form, frevvo permits you to assign * a document [http://bitworking.org/projects/URI-Templates/ URI Template] resolved either using query parameters or form fields. * a Read method and * a Write method. This is best described using several examples. Consider the example above. Here are the interactions a Customer Resource supports: <table cellpadding="3" cellspacing="0" border="1"> <tr> <th>Resource</th> <th>Method</th> <th>Description</th> <th>Returns</th> </tr> <tr> <td>Customer List</td> <td>GET</td> <td>List of customers (may be criteria based)</td> <td>XML list of customers</td> </tr> <tr> <td>Customer List</td> <td>POST</td> <td>Create new customer</td> <td>URI of newly created customer</td></tr> <tr> <td>Customer</td> <td>GET</td> <td>Get customer data</td> <td>XML representation of cutsomer</td></tr> <tr> <td>Customer</td> <td>PUT</td> <td>Update customer</td> <td></td></tr> <tr> <td>Customer</td> <td>DELETE</td> <td>Remove customer</td> <td></td></tr> </table> '''Updating a document''' Consider the case where a form is used to update a particular customer. To create the form: <ol> <li>Upload your customer schema to the designer, add the customer element to the document types for the form and add the customer to the form (which automatically generates controls). See the section on [[V4_Designing_Forms#From_Schema|Adding Controls from Schema]] for further details.</li> <li>Drag/drop, change labels etc. directly in the browser</li> <li>Specify URI template .../customers/{customer}, choose Read Method GET and Write Method PUT</li> <li>Specify a Form Action URI if desired (we'll get to this later).</li> </ol> That's it. As usual, you [[V4_Using_Forms#Sharing_Forms |access the form using its URI]]. When the form is used (instantiated), you may specify one or more query parameters along with the URI. For this example, we might use a URI and query parameter: .../form/1234?customer=02. frevvo will resolve the URI template above to: .../customers/02, GET the customer, and display the initialized form. When the form is submitted, frevvo will automatically PUT the customer document to the same URI thereby updating the customer. The diagram below shows the interactions. [[Image:Update_Customer.jpg]] Here's [http://www.frevvo.com/frevvo/web/user/gallery/app/_73zHwep_EduZgK0BUzi1Ug/formtype/__AKE4PgqEdusGKt5_HoCDw?_method=POST&embed=true&customer=02 an example form] that uses the Customer entity described above. In the example: <ol> <li>We instantiate the form with a parameter customer=02. This causes the form to resolve the URI template and GET the customer data from: http://[server]/customers/02. The resulting XML document provides the initial state of the Customer and is used to initialize the form.</li> <li>Modify a value and click Submit. The form will automatically PUT to the correct resource and update the customer information.</li> <li>Finally, frevvo will store the generated document set and assign it a unique URI. The document set and the documents therein can be [[V4_Using_Forms#Documents|accessed at this URI]].</li> </ol>
...