[xwiki-users] Working with query results...
I have the following code in one of my pages and it does what I am expecting however I'd like to try and generalize it some. #set ($hql = ", BaseObject as obj where obj.name = doc.fullName and obj.className = 'CPA_FAQs.FAQClass' and doc.space='MySpace'") #set($recentDocs = $xwiki.searchDocuments($hql, 5, 0)) #if($recentDocs.size() > 0) <ol> #foreach($entry in $recentDocs) #set($faqDoc = $xwiki.getDocument('MySpace', $entry)) <li>[$faqDoc.question>$faqDoc.fullName]</li> #end </ol> #else #info($noFAQs) #end In this example is $entry an instance of com.xpn.xwiki.api.Object? If so, is there a way to get the space from it without doing $xwiki.getDocument('MySpace', $entry)? I would like to generalize that statement so I can re-use the code for any documents in any space as opposed to having to hard-code the space. Thanks! .:. Kevin -- View this message in context: http://n2.nabble.com/Working-with-query-results...-tp2162883p2162883.html Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi Kevin, Kevin_C wrote:
I have the following code in one of my pages and it does what I am expecting however I'd like to try and generalize it some.
#set ($hql = ", BaseObject as obj where obj.name = doc.fullName and obj.className = 'CPA_FAQs.FAQClass' and doc.space='MySpace'")
#set($recentDocs = $xwiki.searchDocuments($hql, 5, 0))
#if($recentDocs.size() > 0) <ol> #foreach($entry in $recentDocs)
#set($faqDoc = $xwiki.getDocument('MySpace', $entry))
<li>[$faqDoc.question>$faqDoc.fullName]</li>
Here $faqDoc.fullName is the same with $entry
#end </ol> #else #info($noFAQs) #end
In this example is $entry an instance of com.xpn.xwiki.api.Object? If so, is
No, it's http://tinyurl.com/9hxpot
there a way to get the space from it without doing $xwiki.getDocument('MySpace', $entry)? I would like to generalize that
Yes.
statement so I can re-use the code for any documents in any space as opposed to having to hard-code the space.
## Add &space=MySpace to the query string of the URL #set($lookupSpace = $request.space) Hope this helps, Marius
Thanks! .:. Kevin
Marius Dumitru Florea wrote:
Hi Kevin,
Kevin_C wrote:
I have the following code in one of my pages and it does what I am expecting however I'd like to try and generalize it some.
#set ($hql = ", BaseObject as obj where obj.name = doc.fullName and obj.className = 'CPA_FAQs.FAQClass' and doc.space='MySpace'")
#set($recentDocs = $xwiki.searchDocuments($hql, 5, 0))
#if($recentDocs.size() > 0) <ol> #foreach($entry in $recentDocs)
#set($faqDoc = $xwiki.getDocument('MySpace', $entry))
<li>[$faqDoc.question>$faqDoc.fullName]</li>
Here $faqDoc.fullName is the same with $entry
#end </ol> #else #info($noFAQs) #end
In this example is $entry an instance of com.xpn.xwiki.api.Object? If so, is
No, it's http://tinyurl.com/9hxpot
Sorry, $faqDoc is http://tinyurl.com/9hxpot , $entry is simply the full name of the document, thus a string.
there a way to get the space from it without doing $xwiki.getDocument('MySpace', $entry)? I would like to generalize that
Yes.
statement so I can re-use the code for any documents in any space as opposed to having to hard-code the space.
## Add &space=MySpace to the query string of the URL #set($lookupSpace = $request.space)
Hope this helps, Marius
Thanks! .:. Kevin
_______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
## Add &space=MySpace to the query string of the URL #set($lookupSpace = $request.space)
I ended up using this as the code is in a default page for a parent space so I can't add the correct parameter to the Url. #set($space = $entry.substring(0, $entry.indexOf("."))) Thanks for the great info! .:. Kevin -- View this message in context: http://n2.nabble.com/Working-with-query-results...-tp2162883p2163242.html Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (2)
-
Kevin_C -
Marius Dumitru Florea