Last modified by Manuel Leduc on 2023/02/02

<
From version < 21.1 >
edited by Vincent Massol
on 2009/09/08
To version < 22.1 >
edited by Vincent Massol
on 2009/09/08
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -4,6 +4,12 @@
4 4  
5 5  XWiki allows user to access documents and objects with [[HQL>>http://www.hibernate.org/hib_docs/reference/en/html/queryhql.html]] queries in [[Velocity>>http://jakarta.apache.org/velocity/docs/user-guide.html]] scripts.
6 6  
7 +== Public API (##searchDocuments##) ==
8 +
9 +{{velocity}}{{html}}
10 +#info("With this API the query consist in the WHERE condition of a full HQL query. Any user with edit rights can write a script using this API. Any user with view rights can view the result of such a query.")
11 +{{/html}}{{/velocity}}
12 +
7 7  General example showing how to display the first 5 results of a given query:
8 8  
9 9  {{code language="none"}}
... ... @@ -16,12 +16,6 @@
16 16  
17 17  The examples below will show you various HQL queries that you can write.
18 18  
19 -== Public API (##searchDocuments##) ==
20 -
21 -{{velocity}}{{html}}
22 -#info("With this API the query consist in the WHERE condition of a full HQL query. Any user with edit rights can write a script using this API. Any user with view rights can view the result of such a query.")
23 -{{/html}}{{/velocity}}
24 -
25 25  === Simple Query ===
26 26  
27 27  Displays all documents who have been created by the user ##XWiki.JohnDoe##:
... ... @@ -59,6 +59,18 @@
59 59  #warning("Calls to te privileged API are only executed when the calling page has been saved by a user with Programming Rights. The reason is that search can be used to send dangerous HQL command like update, delete, etc.")
60 60  {{/html}}{{/velocity}}
61 61  
62 +General example showing how to display the first 5 results of a given query:
63 +
64 +{{code language="none"}}
65 +#set($hql="<query here>")
66 +#set($results = $xwiki.search($hql, 5, 0))
67 +#foreach ($item in $results)
68 + * $item
69 +#end
70 +{{/code}}
71 +
72 +The examples below will show you various HQL queries that you can write.
73 +
62 62  === Simple Query ===
63 63  
64 64  {{code language="none"}}

Get Connected