Hi Tjaart, all, Tjaart van Wijck wrote:
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
I think we are missing some important point about how objects are retrieved. See this FAQ... http://tinyurl.com/6rgm8h I am not able yet to relate this with Guillaume proposal. He doesn't use .getProperty and I don't know why. And this thread in xwiki-devs... http://tinyurl.com/6j5a2m I will keep this post when I get a simple example. Your feedback will be really welcome! Cheers, Ricardo -- Ricardo RodrÃguez Your EPEC Network ICT Team