[daisy] Gettings contents of documentBasket on other pages
Bruno Dumon
bruno at outerthought.org
Wed May 2 03:21:21 CDT 2007
On Sun, 2007-04-29 at 14:43 +0200, Vincent Mouton wrote:
> Hello,
>
> I was wondering if there's a way (an ext for example) to get the contents of
> the document basket on other pages of a site, besides the /documentBasket/**
> pages.
> I don't need the entire documents. The number of documents, or their
> name/docId is enough.
>
> I know how to create an ext, but I can't seem to find a way to pull the
> contents of the docbasket in.
>
Rather than going through the DocumentBasketApple, this approach might
be simpler.
Create some flowscript like this:
importClass(Packages.org.outerj.daisy.frontend.components.docbasket.DocumentBasketHelper);
function showBasketSize() {
// the false argument means the basket instance should not be created
// if it does not exist yet
var documentBasket = DocumentBasketHelper.getDocumentBasket(cocoon.request, false);
var numberOfDocs = 0;
if (documentBasket != null) {
numberOfDocs = documentBasket.size();
}
// and then pass that to a pipeline through the viewData
var viewData = {};
viewData["documentBasketSize"] = numberOfDocs;
sendPage("BasketSizePipe", viewData);
}
The sitemap could be something like this:
<map:match pattern="basketSize">
<map:call function="showBasketSize"/>
</map:match>
<map:match pattern="BasketSizePipe">
<map:generate type="jx" src="page.xml"/>
<map:serialize type="xml"/>
</map:match/>
and page.xml could look like:
<div>
Number of documents in basket: ${documentBasketSize}
</div>
Instead of passing just the size, you could of course pass the complete
DocumentBasket object.
I havn't tested any of the above, so there might be typos in there :-)
--
Bruno Dumon http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno at outerthought.org bruno at apache.org
More information about the daisy
mailing list