inicio mail me! sindicaci;ón

Visual REST apps: Part 1 – view/edit Entities

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:

  1. 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.
  2. 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.
  3. If you modify a value and click Submit, the form will automatically PUT to the correct resource and update the customer information.
  4. 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.

Bookmark at: del.icio.us | Digg

RESTful design of complex Web forms « Noelios Consulting said,

May 4, 2007 @ 8:19 am

[…] Recently, they have been playing with Restlet and implemented one of the REST design pattern (”View and Entity resources”) that was discussed by the Restlet community. It is a very compelling illustration that REST applications are perfectly capable of handling complex Web forms without compromising with the REST principles. […]

frevvo blog » Visual REST apps: Part 2 – documents said,

May 9, 2007 @ 8:17 am

[…] 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. […]

Dev::Info said,

May 13, 2007 @ 9:24 am

AJAX + REST…

Dvoudílný článek, popisující spojení technologie AJAX s protokolem REST, zveřejnil Ashish Deshpande na Frevvo blogu . Toto spojení komentuje provokativní otázkou Ajax+REST: the next killer app?

Ajax+REST=the next killer app? | Ajax Blog said,

May 16, 2007 @ 11:40 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. […]

Ajax+REST=the next killer app? said,

May 16, 2007 @ 11:41 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. […]

frevvo blog » Ajax+REST: the next killer app? said,

May 25, 2007 @ 8:24 am

[…] I’ve been experimenting with creating these rich applications (see these articles) and I really believe that Ajax+REST is the next killer app. I came across this article by Tim Ewald, in which he discusses how he finally gets REST. As mentioned in the article, a RESTful application is part of the web rather than running on top of the web (hypermedia as the engine of application state). Like the general web, the application is a set of states traversed via URIs (each state contains links (URIs) to other states that can be reached from itself). […]

frevvo blog » Java vs Microsoft for SOA said,

August 28, 2007 @ 2:49 pm

[…] This is exactly in line with our thinking here at frevvo (also see Visual REST applications Part 1 and Part 2). […]

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

September 6, 2007 @ 12:02 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. […]

Ajax+REST=the next killer app? » Feed My News said,

December 1, 2007 @ 1:14 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. […]

Creative Glance Technologies » Blog Archive » Ajax+REST=the next killer app? said,

March 1, 2008 @ 2:46 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. […]

Bill Bartmann said,

September 2, 2009 @ 11:47 pm

Excellent site, keep up the good work

sandra407 said,

September 9, 2009 @ 10:44 am

Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.

angelina jolie said,

September 10, 2009 @ 11:10 am

I love your site. :) Love design!!! I just came across your blog and wanted to say that Ive really enjoyed browsing your blog posts. Sign: ndsam

megan fox said,

September 11, 2009 @ 10:39 am

Sign: umsun Hello!!! rcuwwymhyw and 4039ssgfhphzye and 823I will try to recommend this post to my friends and family, cuz its really helpful.

RSS feed for comments on this post · TrackBack URI

Leave a Comment