That's very good.   It means that out of the box sling support lists of nodes.

However, I have the feeling that the approach is not consistent with
the processing of a simple resource.

Following the Lars cheatsheet, I would have expected to have the step
2 (content resolution) being able to handle queries, and then having
step 3 deriving a nice ressource type (employee/list for instance)
followed then by normal rendering steps.

That would allow for instance to have list rendered into xml of html,
and not only json.  And moreover, I feel that would have made the
model more consistent.

Is my point of view correct, or did I have the wrong paradigm glasses?

My jcr-foo is too limited to say if such approach would be possible,
and if it is it will certainly require some magic.  But when I look at
sling, it is what I see : 'Magic'.


Gilles Scokart


2008/7/21 Bertrand Delacretaz <[EMAIL PROTECTED]>:
> On Sat, Jul 19, 2008 at 7:31 PM, Gilles Scokart <[EMAIL PROTECTED]> wrote:
>
>> ...But what If I want to list all employees in a page or as a result of
>> an AJAX call?  Did I have to use the url of the parent node of all the
>> employee and map that to a rendering script that I have to write ?  Is
>> there any default rendering for list ?...
>
> The json rendering is recursive, so if you have a node
> /content/employees that contains many employee nodes, you can list
> them all at once by requesting /content/employees.infinity.json, or
> /content/employees.2.json if you want only 2 levels, etc.
>
>>
>> ...And what if I only want a sublist (as a result of a query for instance) 
>> ?...
>
> Then yes you'll need a query - the simplest way is to use the
> JsonQueryServlet which you'd call for example like
>
>  /content/employees.query.json?statement=...&queryType=...&offset=10&rows=10
>
> See JsonQueryServletTest [1] for (a few) examples. The offset/rows
> parameters are used for paging through results.
>
> -Bertrand
>
> [1]  
> http://svn.eu.apache.org/repos/asf/incubator/sling/trunk/launchpad/webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JsonQueryServletTest.java
>

Reply via email to