Hi, My problem is still unresolved. I have followed the suggestions from the FAQ post: http://www.xwiki.org/xwiki/bin/view/FAQ/HowToListDocumentsWithACertainProper... And rewrote the code as follows: #set($query="select obj from BaseObject obj where obj.className='Contacts.ContactClass'") #set($results=$xwiki.search($query, 10, 1)) #foreach($item in $results) #set($doc=$xwiki.getDocument($item)) #set($obj=$doc.getObject('Cotacts.ContactClass')) #set($firstname=$obj.getProperty('firstname').value) #set($surname=$obj.getProperty('surname').value) #set($phone1=$obj.getProperty('phone1').value) $firstname | $surname | $phone1 <br /> #end With the result: $firstname | $surname | $phone1 $firstname | $surname | $phone1 I should add that I would have been confused if the above had worked. Please let me know if my understanding of the object model is correct: a) A class definition is essentially a special type of wiki page that defines the class structure (i.e. properties). b) No more than 1 class definition can be contained in this special type of page. c) Objects are instances of these classes and must be associate with a page. (Can a single object be associated with more than 1 page?) d) Multiple objects can be associated with a wiki page. e) An HQL query iterates through the wiki pages, through each object in each page and each property in each object d) An HQL query specifying page/document constraints returns a Java List of documents e) An HQL query specifying object constraints returns a Java List of objects (does not seem to be the case from the above code?!) f) An HQL query specifying property constraints returns a Java List of properties Regards, Tjaart On 15/04/2008, [Ricardo Rodriguez] Your EPEC Network ICT Team < [email protected]> wrote:
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...
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...
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
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users