Jerome,

> To me, it seems fine if the Web representation of the resource "thread
> number 3 of the help forum" contains navigation data and other contextual
> help. This is just how you "represent" your resource on a Web page. The same
> resource could expose a more focus XML representation for programmatic
> clients.
> 
> Now, in term of coding, your ThreadResource class should have access to all
> the domain objects (POJOs) required to return the Web representation:
> Thread, User, Connections, etc.

So you're forcing one resource to be aware of other resources just because of
the way your user interface in designed. If you switch to HTML frames, you no
longer need these dependencies because each frame displays only one resource
(the content frame, the profile frame, the navigation frame, etc.). 

And what about cross references? If you click on a post in one of the thread, 
the 'post' resource must know about the 'profile' resource because it's 
part of its 'contextual information'. Now let's say you have a 'More' link in
the profile section to display more of your profile info. In order to redisplay
the page, the 'profile' resource will have to know about the 'post' resource
too (because when you GET /profile/123;details, you need to include the
current post). Imagine the graph (and the resulting maintenance nightmare) if 
you  have 5 resources displayed on one page.  

And what if the same resource can be displayed in several type of views? Take
this forum, for instance: 
When you a click on a thread, the post is displayed in the bottom part of the
screen. You can also click on the direct-link and have the post displayed on a
new page (without the threads). gmane uses frames to achieve this, but how would
you do it without frames? Include the view in the url?

GET http://article.gmane.org/gmane.comp.java.restlet/1871;view=threaded
GET http://article.gmane.org/gmane.comp.java.restlet/1871;view=single

Or you could decide that what you're viewing is the form, and the uri becomes:
GET http://article.gmane.org/gmane.comp.java.restlet?activeView=1871

The danger with this approach is that it forces you to think in terms of pages
(the forum, the main page, etc.) instead of resources. Or more exactly: 
your pages become your resources.


I've been thinking a lot about this too, and I came to the conclusion that 
the best way to put a face on a restfull app is the have the client -not
the server- assemble the view.
The simplest (an ugliest) way is to use frames; a better solution is
to make Ajax calls to the server to retrieve individual resources, and 
insert the returned html (or xml, json, etc) in the page.
It also scales better if the application is stateless (no need to retrieve the
profile each time we display a post). 
Of course, this is valid only for relatively complex application(e.g. a webmail
 client). But if your application is restul and your UI moderately complex, it
calls for a single-page UI (a la GWT) as opposed as the standard multi-page
design. 

-vincent
 

Reply via email to