Jean-Vincent,

Thanks.

Seems that the line:
#set($class = $bentrydoc.getObject("XWiki.ArticleClass").xWikiClass)
seemed to cause the $class not to get set and
"$bentrydoc.display($prop.name,"view", $class)" not to evaluate and just got
displayed on the page - removing ".xWikiClass" solved the problem i.e. 
#set($class = $bentrydoc.getObject("XWiki.ArticleClass"))
Was ".xWikiClass" just a typo?
Also "<td> *${prop.prettyName}* </td>" didn't evaluate and just got
displayed on the page!

So my working code is now:

#set ($list = $xwiki.search("select doc.fullName from XWikiDocument doc,
BaseObject obj, StringProperty prop where doc.fullName=obj.name and
obj.className='XWiki.ArticleClass' and prop.id.id=obj.id and
prop.name='title' and prop.value like 'Art%'", 5, 0))

#foreach ($item in $list)
#set($bentrydoc = $xwiki.getDocument($item))

#set($class = $bentrydoc.getObject("XWiki.ArticleClass"))
$bentrydoc.name

<table border="1" cellspacing="0" cellpadding="2">
#foreach($prop in $class.properties)
<tr>
<td> *${prop.name}* </td>
<td> 
$bentrydoc.display($prop.name,"view", $class)
</td>
</tr>
#end
</table>

#end

I might try your refactored code as well - thank :)

Regards,

Richard

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
Jean-Vincent Drean
Sent: 10 October 2007 09:58
To: XWiki Developers
Subject: Re: [xwiki-devs] Ref: Displaying lists of wiki pages given a
set of criteria


2007/10/9, goldring, richard <[EMAIL PROTECTED]>:
> #set ($list = $xwiki.search("select doc.fullName from XWikiDocument doc,
> BaseObject obj, StringProperty prop where doc.fullName=obj.name and
> obj.className='XWiki.ArticleClass' and prop.id.id=obj.id and
> prop.name='title' and prop.value like 'Art%'", 5, 0))

Remember that you'll get only the 5 first results with this call :
http://build.xpertnet.biz/latestdoc/api/com/xpn/xwiki/api/XWiki.html#search(
java.lang.String,%20int,%20int)

from :
http://build.xpertnet.biz/latestdoc/api/com/xpn/xwiki/api/package-summary.ht
ml

> #foreach ($item in $list)
> #set($bentrydoc = $xwiki.getDocument($item))
>
> #set($class = $bentrydoc.getObject("XWiki.ArticleClass").xWikiClass)
> $bentrydoc.name
> <table border="1" cellspacing="0" cellpadding="2">
> #foreach($prop in $class.properties)
> <tr>
> <td> *${prop.prettyName}* </td>
> <td>Value: $doc.display($prop.value)</td> <--- this line!
> </tr>
> #end
> </table>

While you know the type of the object you want to display you don't
have to use the xWikiClass (which is privileged API).
You can consult the list of the class properties at :
/xwiki/bin/edit/XWiki/ArticleClass?editor=class (class editor,
accessible from the top menu).

I'd refactor your snippet like this :

#foreach ($item in $list)
  #set($bdoc = $xwiki.getDocument($item))
  $bdoc.title
  <table border="1" cellspacing="0" cellpadding="2">
    <tr>
      <td> *Title* </td>
      <td>$bdoc.display("title")</td>
    </tr>
    <tr>
      <td> *Category* </td>
      <td>$bdoc.display("category")</td>
    </tr>
    <tr>
      <td> *Content* </td>
      <td>$bdoc.display("content")</td>
    </tr>
  </table>
#end

JV.
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Thales UK Ltd (Wells) DISCLAIMER: The information contained in this e-mail
is confidential. It may also be legally privileged. It is intended only for
the stated addressee(s) and access to it by any other person is
unauthorised. If you are not an addressee, you must not disclose, copy,
circulate or in any other way use or rely on the information contained in
this e-mail. Such unauthorised use may be unlawful. We may monitor all
e-mail communications through our networks. If you have received this e-mail
in error, please inform us immediately on +44 (0) 1749 672081 and delete it
and all copies from your system. We accept no responsibility for changes to
any e-mail which occur after it has been sent.  Attachments to this e-mail
may contain software viruses which could damage your system.  We therefore
recommend you virus-check all attachments before opening. A business of
Thales UK Ltd. Registered Office: 2 Dashwood Lang Road, The Bourne Business
Park, Addlestone, Weybridge, Surrey KT15 2NX Registered in England No.
868273
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to