Hi,

2009/2/24 Felix Meschberger <fmesc...@gmail.com>:
> ...SLING-344 [1] added the StarResource [2] to support requests to
> explicitly unknown resources like /* or /*.html. One feature of this
> class is, that it adapts to a "FakeNode"....

Yes, the use case for that is when building a simple CRUD application.

Requesting the StarResource and adapting that to a Node provides you
with empty values for all the node's properties, so if using the
sling.wizard() from sling.js you have no code to write for the Create
action - it is handled just like the Update action, but works on the
"magic" star resource.

The only difference between Create and Update in this case, is that
for Create you retrieve the * resource (which initializes all your
fields to empty values), whereas for Update you retrieve the actual
resource that was created before.

See my "blog in 46 lines" example at
http://dev.day.com/microsling/content/blogs/main/sling-46-lines-blog.html
for an actual mini-app that uses this feature.

> ...having a
> synthetic resource not backed by a JCR item return a non-null result for
> adaptTo(Node.class) is kind of strange.
>
> For this reason, I suggest remove the Node adapter functionality of the
> StarResource, such that
>
>        StarResource.adaptTo(Node.class) == null...

Although I see the idea, that would break the above use case. I'm open
to suggestions for providing that functionality in another way, but
don't have much time to look at it myself at the moment.

-Bertrand

Reply via email to