Hi Guillaume,

Thanks for the advise but it still doesn't work. I've implemented:

#set($query="select obj from BaseObject obj where
obj.className='Contacts.ContactClass'")
#set($results=$xwiki.searchDocuments($query, 10, 1))
#foreach($item in $results)
#set ($itemdoc = $xwiki.getDocument($item))
#set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))
$itemobject.display('firstname') | $itemobject.display('lastname') |
$itemobject.display('phone1')  <br />
#end

But get the error:

Error number 4001 in 4: Error while parsing velocity page
Contacts.Contacts Directory Wrapped Exception: Invocation of method
'searchDocuments' in class com.xpn.xwiki.api.XWiki threw exception
com.xpn.xwiki.XWikiException: Error number 3223 in 3: Exception while
searching documents with SQL web, doc.name from XWiki Document as doc
where select obj from Base Object obj where obj.class
Name='Contacts.Contact Class'? Wrapped Exception: unexpected token:
select near line 1, column 85 web, doc.name from
com.xpn.xwiki.doc.XWiki Document as doc where select obj from
com.xpn.xwiki.objects.Base Object obj where obj.class
Name='Contacts.Contact Class'? @ Contacts.Contacts Directory2,22

I also tried this with $itemdoc.display(...) as you suggested but that
is not the source of the problem.

Am I right in suspecting that HQL queries like "select doc from
XWikiDocument..." will return a resultset of "XWikiDocuments" but a
HQL query like "select obj from BaseObject..." will return a resultset
of BaseObjects. I think the cause of the exception might be that
seachDocuments should requires a doc resultset as parameter.

Any ideas?

Thanks.

On 15/04/2008, Guillaume Lerouge <[EMAIL PROTECTED]> wrote:
> Hi Tjaart,
>  Here we go at last :
>
>
>  #set($query="select obj from BaseObject obj where obj.className='Contacts
>  .ContactClass'")
>
> #set($results=$xwiki.searchDocuments($query, 10, 1))
>  #foreach($item in $results)
>
>  #set ($itemdoc = $xwiki.getDocument($item))
>
>  #set ($itemobject = $itemdoc.getObject('Contacts.ContactClass'))
>
>  $itemdoc.display('firstname')
>  | $itemdoc.display('lastname') | $itemdoc.display('phone1')  <br />
>
>  #end
>
>
>  Hopefully this will work...
>
>
>
>  Guillaume
>
> _______________________________________________
>  users mailing list
>  users@xwiki.org
>  http://lists.xwiki.org/mailman/listinfo/users
>
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to