Thanks for the help but unfortunately this still does not solve my problem.

1) Your first suggestion:

#foreach($item in $results)
$item.getObject('Contacts.ContactClass')
$item.display('firstname') | $item.display('lastname') |
$item.display('phone1') <br />
#end

Produces:
$item.getObject('Contacts.ContactClass') $item.display('firstname') |
$item.display('lastname') | $item.display('phone1')
$item.getObject('Contacts.ContactClass') $item.display('firstname') |
$item.display('lastname') | $item.display('phone1')


2) The second suggestion:

#foreach($item in $results)
$item.getObject('Contacts.ContactClass')
$item.firstname | $item.lastname | $item.phone1 <br />
#end

Produces:
$item.getObject('Contacts.ContactClass') $item.firstname | $item.lastname |
$item.phone1
$item.getObject('Contacts.ContactClass') $item.firstname | $item.lastname |
$item.phone1

I also tried:

#foreach($item in $results)
#set($obj=$item.getObject('Contacts.ContactClass')
 $obj.firstname | $obj.lastname | $obj.phone1 <br />
#end

But produces :

$obj.firstname | $obj.lastname | $obj.phone1
$obj.firstname | $obj.lastname | $obj.phone1

Any insight would be appreciated.

-Tjaart


On 15/04/2008, Guillaume Lerouge <[EMAIL PROTECTED]> wrote:
>
> 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
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
>
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to