[daisy] Daisy Calendar Extension

wildcabayo-daisy at yahoo.com wildcabayo-daisy at yahoo.com
Fri Mar 7 19:59:37 CET 2008


I've been trying to build on the calendar tutorial and have run into a snag and showstopper in my learning process. I was hoping someone with more experience will come along and point out what I'm doing wrong.
   
  I added a function to the calendar.js file to return a previous month's event data. It's a modified knockoff of the showCalendar function that was provided in the tutorial. Also, I modified the sitemap.xmap by copying the sample pipeline and calling it pcalendar (for previous month's event data), but, for some reason, the data that it returns is always the current month.  I can't for the life of me figure out what I'm doing wrong.  Please help?  Thanks in advance.
   
  ::: added to calendar.js :::
   
  function showPreviousMonthCalendar() {
  var daisy = new Daisy();
  var pageContext = daisy.getPageContext();
  
  var beginOfMonth = new GregorianCalendar();
  beginOfMonth.add(Calendar.MONTH,-1);
  beginOfMonth.set(Calendar.DAY_OF_MONTH, 1);
  
  var endOfMonth = new GregorianCalendar();
  endOfMonth.add(Calendar.MONTH,-1);
  endOfMonth.set(Calendar.DAY_OF_MONTH,1);
  endOfMonth.set(beginOfMonth.DAY_OF_MONTH, beginOfMonth.getActualMaximum(Calendar.DAY_OF_MONTH));
  
  var queryManager = daisy.getRepository().getQueryManager();
  
  var sQry = "select $EventDate, name where documentType = 'Event'"
  +" and $EventDate between "
  + QueryHelper.formatDate(beginOfMonth.getTime()) + " and "
  + QueryHelper.formatDate(endOfMonth.getTime());
  
  var events = queryManager.performQuery(sQry, java.util.Locale.US); 
  
  var viewData = new Object();
  viewData["pageContext"] = pageContext;
  viewData["events"] = new XmlObjectXMLizable(events);
  cocoon.sendPage("pCalendarPipe", viewData);
  }
   
   
  ::: added to sitemap.xmap :::
   
  <map:pipeline internal-only="true" type="noncaching">
  <map:parameter name="outputBufferSize" value="8192"/>
  <map:match pattern="previousMonthCalendar">
  <map:generate type="calendar"> 
  <map:parameter name="dateFormat" value="M/d/yy"/>
  <map:parameter name="lang" value="en"/>
  <map:parameter name="country" value="US"/>
  </map:generate>
  <map:serialize/>
  </map:match>
  <map:match pattern="pCalendarPipe">
  <map:generate type="jx" src="pcalendar.xml"/>
  <map:transform type="cinclude"/>
  <map:transform src="pcalendar.xsl"/>
  <map:transform src="daisyskin:xslt/layout.xsl"/>
  <map:transform type="i18n">
  <map:parameter name="locale" value="{request-attr:localeAsString}"/>
  </map:transform>
  <map:serialize/>
  </map:match>
  </map:pipeline>
  <map:pipeline type="noncaching">
  <map:parameter name="outputBufferSize" value="8192"/>
  <map:match pattern="pcalendar">
  <map:call function="showPreviousMonthCalendar"/>
  <map:serialize/>
  </map:match>
  </map:pipeline>
   
  ::: contents of pcalendar.xml :::
  <?xml version="1.0"?>
  <page xmlns:cinclude="http://apache.org/cocoon/include/1.0">
  ${pageContext}
  ${events}
  <cinclude:include src="cocoon:/previousMonthCalendar"/>
  </page>
   
  ::: pcalendar.xsl is an exact duplicate of the tutorial's calendar.xsl :::
   
  In my testing, I've been able to fetch previous and latter months events as an XML resultset using a simple pipeline in sitemap.xmap that has no transformations, an addition of a map parameter field with a hardcoded value for the month and a directive to serialize the data as XML.
   
  I've also tested and debugged my javascript to ensure that my beginOfMonth and endOfMonth object is set to a previous month.
   
  I've even gone down to barebones and left just my versions of the sample code in calendar.js and sitemap.xmap but no matter what I do, when I put it all together and make a call to my pipeline, i.e. (http://{myserver}:8888/{myarea}/ext/tester/pcalendar}  I get the current month's data.
   
  What am I missing??
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cocoondev.org/pipermail/daisy/attachments/20080307/d504577e/attachment.htm


More information about the daisy mailing list