[daisy] Gettings contents of documentBasket on other pages

Vincent Mouton vincent at postback.be
Tue May 1 01:34:22 CDT 2007


> 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.
> 

I've done some, uhm, hacking myself, and found a solution. Allow me to share
for future generations... (and because I still have an issue).

1. I've created an extension, of course, adding a directory called
'docbasket' here: <daisywiki>\sites\<sitename>\cocoon\docbasket
2. I added a sitemap.xmap file with the XML you'll find below. It is a
simple subset of what can be found in daisy's sitemap.
I leave out obvious and empty <map:components>, <map:views>, <map:resources>
tags in this snippet

  <map:flow language="apples"/>
  <map:pipelines>
     <map:pipeline type="noncaching">
     <map:parameter name="outputBufferSize" value="8192"/>
       <map:match pattern="internal/**">
         <map:match pattern="internal/genericPipe">
           <map:generate type="jx" src="{flow-attr:pipeConf/template}"/>
           <map:act type="JXTestAction">
             <map:parameter name="test" value="pipeConf/hasStylesheet"/>
             <map:transform src="resources/xslt/docbasket.xsl"/>
           </map:act>
           <map:act type="JXTestAction">
             <map:parameter name="test" value="pipeConf/applyI18n"/>
             <map:transform type="i18n">
               <map:parameter name="locale"
value="{request-attr:localeAsString}"/>
             </map:transform>
           </map:act>
           <map:serialize type="xml"/>
         </map:match>
       </map:match>
      <map:match pattern="getbasket">
        <map:call function="org.outerj.daisy.frontend.DocumentBasketApple"/>
      </map:match>
   </map:pipeline>
 </map:pipelines>


3. I also placed a 'resources' folder in the folder of the ext, with inside
that folder a 'xml' folder, like:
<daisywiki>\sites\<sitename>\cocoon\docbasket\resources\xml
4. I placed a page.xml and a docbasket.xml file (and threw out things like
pageContext etc). It's up to you to alter these as you wish. I grabbed the
original fils from %DAISY_HOME%\daisywiki\webapp\daisy\resources\xml
5. I created a xsl file that transforms the result from the
DocumentBasketApple (see the <map:transform
src="resources/xslt/docbasket.xsl"/> entry above)
6. And then, of course, calling the ext through the einclude mechanism:
<einclude:include src="cocoon://<sitename>/ext/docbasket/getbasket"/>


Works like a charm, except for one thing.

All over the site, we added a link to add the document you're currently
looking at, to the document basket. And a counter that shows how much
documents are in the basket (done through the ext described above).

When we execute the action to add a document to the basket, the POST is
executed, the document is added to the basket, yet when the response gets
back, the einclude described above shows us this exception:

Error processing inclusion of cocoon://<sitename>/ext/docbasket/getbasket :
Sitemap: error calling function
'org.outerj.daisy.frontend.DocumentBasketApple' at <map:call> - 
file:/C:/daisy/wikidata/sites/<sitename>/cocoon/docbasket/sitemap.xmap:44:77
at <map:mount> - 
file:/C:/daisy/wikidata/sites/<sitename>/cocoon/sitemap.xmap:25:87 at
<map:mount> - 
file:/C:/daisy/daisy-2.0.1/daisywiki/webapp/daisy/sitemap.xmap:850:154 at
<map:mount> - 
file:/C:/daisy/daisy-2.0.1/daisywiki/webapp/sitemap.xmap:637:63, cause:
Invalid request: parameter "basketAction" is missing.



Any pointers?

Cheers,
v



More information about the daisy mailing list