Hi Ryan


Ryan Gardner wrote:
(I've tried running a <cms:query to get a collection and then passing that collection to a contentNodeIterator... no luck -


I once stumbled upon some example of how to do a JCR query from
a JSP but I lost that somehow...


Anyone have an example of how to do this?


Normally I need to check the data from module data a bit more, thats
why I created a jsp tag to do the job. From the tag definition I
have something similar to:


private NodeIterator doQuery () {

QueryManager queryManager =
  MgnlContext.getSystemContext().getQueryManager("data");

StringBuffer query = new StringBuffer("/jcr:root/yourNode/");

query.append("what ever you need");

Query jcrQuery =  queryManager.createQuery(query.toString(), XPATH);
QueryResultImpl queryResult = (QueryResultImpl) jcrQuery.execute();

QueryResult result = queryResult.getJcrResult();

return result.getNodes();

}

This will return a NodeIterator. You can then step through that
node iterator to get all the nodes from the result.

Hope that helps
Cheers,

  Patrick




----------------------------------------------------------------
for list details see
http://documentation.magnolia.info/docs/en/editor/stayupdated.html
----------------------------------------------------------------

Reply via email to