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


Which is incorrect. Please help, I've been struggling for quite a while and
getting really frustrated.

Thanks.
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to