On 4/10/07, Jeff Walter <[EMAIL PROTECTED]> wrote:
[...]
I'd like to know how many other people are using Restlet to build visual web
applications, and how they feel about aggregating resource data on their
pages?

What do you mean by "visual" web applications? I'm going to presume
that you mean "for consumption by humans" as opposed to use as e.g. a
programmatically accessible "API".

Let's take a simple example:

We have a Resource for a thread on a forum:
http://somesite.org/forums/helpforum/threads/3

On this page, we display the thread Resource, but we also want to show in a
sidebar, lets say other online users browsing the help forum, and the latest
3 posts to the help forum (the actual data is unimportant, but the fact that
the data is not a part of the single thread Resource is).

In Restlet, accessing this URL would load up a Thread Resource and pick its
HTML representation (let's say using a Freemarker template).  To display the
extraneous data in the sidebar, the Thread resource is going to have to
access other Resources information to then pass to the template.
Additionally, if this forum requires that a user be logged-in to participate
in discussions, the header on the page might contain a "logout" link if the
user is logged in (or "login" link if they weren't already logged-in).

Having "extraneous" information on a web page is pretty common requirement,
but it seems to not "feel right" to me in terms of Resource implementation
in Restlet.  How do people feel about Resources loading the extra Resource
data to feed to the templates?  Is this just par for the course and
necessary? Are there best practices people like to employ to accomplish this
without feeling like you are defeating the nice separation of Resources the
framework creates for you?

I think it's helpful to think in terms of fundamental, "base"
resources and composite, "view" resources.  An analogy is the
difference between "tables" and "views" in a relational database such
as Oracle.

As you noted, in your example, it could be modelled where the same URL
is used but the two facets are distinguished by whether the caller
asks for the base (e.g., application/xml) or a human version (e.g.,
xhtml).

For other cases, I think it makes more sense to have the facets more
or less completely disjoint.  The human useful, composite views may
make a lot more sense to the user if they have their own naming
hierarchy, etc. and just use the various, lower-level resources as
services, if you will, that are managed separately.

Hope this helps,
John

Reply via email to