If you’re doing anything with web applications, you’ve probably heard of REST – an architectural style for creating web services. There’s plenty of literature on the Internet that explains REST so I won’t go into details here.
I’ve been thinking/experimenting with building RESTful visual web apps using frevvo and Restlet and came across an interesting discussion on this topic. As noted there, it’s very useful to think in terms of fundamental base resources and composite view resources analogous to the difference between tables and views in a database. I prefer to think in terms of two kinds of first class resources: Entity Resources and View Resources, where a View Resource typically composes one or more entity resources as the diagram shows.

I put together some interesting examples using frevvo. Here are the two entities – Customer and Lists of Customers and the methods they support.
| Resource | Method | Description |
|---|---|---|
| Customer List | GET | List of customers (may be criteria based) |
| Customer List | POST | Create new customer |
| Customer | GET | Get customer data |
| Customer | PUT | Update customer |
| Customer | DELETE | Remove customer |
In frevvo, forms (View Resources) use URIs like:
| URI | Method | Description |
|---|---|---|
| …/formtype/{formtype.id} | POST | Create a new form instance |
| …/form/{form.id} | GET | Get form (XHTML) |
| …/form/{form.id} | POST | Submit form |
The diagram below shows the interactions between the browser, form and entities.

When designing a form, you can specify one or more URI templates for the entity resources that it composes. When the form is used, it does a GET on each [resolved] URI and displays the form with the resulting initial data. When it is submitted, the form automatically PUTs each document to its URI thereby updating the resources.
Here’s an example (should open in a new window) that uses the Customer entity described above. In the example:
- 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 and display the initialized form.
- In addition, the form has an ID field at the top. This ID field is also linked to the URI template. Try changing it to 03 or 04 or 05. You’ll notice that the form automatically GETs the new resource and refreshes the controls.
- If you modify a value and click Submit, the form will automatically PUT to the correct resource and update the customer information.
- If you type an ID that does not exist, the form will be blank since the GET returns an empty document. If you fill in the fields and Submit, the form will PUT to the new URI. In this case, the PUT handler creates the customer.
In this way, the View Resource provides an XHTML representation using which one or more Entity Resources may be viewed and edited. How was this form created? Simply by uploading an XML schema (included in the download), generating the form from the schema, re-arranging a few controls and providing the appropriate document URLs. Not a single line of code.
You can download the complete example including the entity resources and frevvo forms. There’s a lot more you can do with frevvo and RESTful services including using them in rules, viewing/updating multiple documents etc. and I’ll describe some of that in future articles.

