inicio mail me! sindicaci;ón

Visual REST apps: Part 2 – documents

In the previous article (Part 1), I discussed an example application that uses a frevvo form to compose entity resources into a view resource that can be used to update the entities.

frevvo forms are very flexible in the way they can interact with Entity resources (documents). We can say that using the form is equivalent to editing one or more documents. For each document that the form edits, you can specify:

  • a URI template
  • a Read Method – empty, GET or POST
  • a Write Method – empty, PUT, POST or DELETE

Consider the example from Part 1. Here are the 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

Consider the case where the form is used to update customer information. To create the form:

  1. Upload your customer schema to the designer and add the customer to the form (which automatically generates controls)
  2. Drag/drop, change labels etc. directly in the browser
  3. Specify URI template …/customers/{customer}, choose Read Method GET and Write Method PUT
  4. Specify a Form Action URI if desired

That’s it. You can access the form using its URI and a query parameter: …/form/1234?customer=ashish. The URI template above will be resolved to: …/customers/ashish. The diagram below shows the interactions.

Instead of updating a customer, let’s say you want to create a new customer. Just change the Read method to POST and use the URI template: …/customers/. frevvo will perform the POST and follow the server redirect to the newly created resource. When the form is submitted, the newly created customer will automatically be updated. The diagram below shows the interactions.

This is applicable independently to each document that the form edits. If the form is editing Customer, Bill and Order documents, you can specify independent URI templates and read/write methods for each document and frevvo will automatically read/write them using the appropriate URI & method.

In this manner, the combination of URI templates, read/write methods and form parameters provides a very powerful and flexible way to interact with the web. You can easily create REST applications that handle complex visual elements without compromising REST principles.

In the next post, I’ll show you how easily frevvo can create and locally store documents (resources) for you. These documents can also be accessed using simple HTTP URIs.

Bookmark at: del.icio.us | Digg

RESTful design of complex Web forms « Noelios Consulting said,

May 10, 2007 @ 1:57 am

[…] Visual REST apps: Part 2 – documents […]

Ajax+REST=the next killer app? said,

August 9, 2007 @ 6:53 am

[…] On the frevvo blog, I posted several interesting articles about combining Ajax-based RIAs (Rich Internet Applications) with REST web services. It seems to me that Ajax+REST could be the next killer application. […]

Javascript News » Blog Archive » Ajax+REST=the next killer app? said,

September 6, 2007 @ 2:42 pm

[…] On the frevvo blog, I posted several interesting articles about combining Ajax-based RIAs (Rich Internet Applications) with REST web services. It seems to me that Ajax+REST could be the next killer application. […]

RSS feed for comments on this post · TrackBack URI

Leave a Comment