Hi Tjaart,
I have created the class Contacts.ContactClass. This class has three string properties "firstname", "surname" and "phone1". I have also created two instances of this class and filled out the attributes.
Now, it should be straight forward to write a Velocity script to seach for all objects with the given class type of "Contacts.ContactClass" and write out the attributes but I'm having some trouble. Below is my script: #set($query="select obj from BaseObject obj where obj.className='Contacts.ContactClass'") #set($results=$xwiki.search($query, 10, 1)) #foreach ($item in $results) $item.get("firstname") | $item.get("surname") | $item.get("phone1") <br /> #end
However this does not work. All I get is:
$item.get("firstname") | $item.get("surname") | $item.get("phone1") $item.get("firstname") | $item.get("surname") | $item.get("phone1")
When I run:
#set($query="select obj from BaseObject obj where obj.className='Contacts.ContactClass'") #set($results=$xwiki.search($query, 10, 1)) #foreach ($item in $results) $item #end
I get:
Contacts.Tjaart 0 Contacts.ContactClass Contacts.Jane 0 Contacts.ContactClass
Have you tried with : #foreach($item in $results) $item.getObject('Contacts.ContactClass') $item.display('firstname') | $item.display('lastname') | $item.display('phone1') <br /> #end or #foreach($item in $results) $item.getObject('Contacts.ContactClass') $item.firstname | $item.lastname | $item.phone1 <br /> #end ? Hope this helps, Guillaume