cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ricardo Rocha <rica...@apache.org>
Subject Re: Thoughts on a data-driven web site
Date Fri, 23 Jun 2000 02:22:43 GMT
Jonathan Stimmel wrote:

> A related point: how can a taglib maintain state across all pages
> which use it? For instance, could you write a counter tag that would
> track how many times it was hit across all pages that reference it?
> I suppose you could store a field in a database somewhere, but a
> static variable in a class would be much cleaner. (Of course, I
> don't know why you'd want this particular function... =)

<xsl:stylesheet xmlns:...>
  <xsp:page>
    <xsl:apply-templates select="@*"/>
      <xsp:logic>
        private static int counter = 0;
        private static synchronized int hitCount() {
          return ++counter;
        }         
      </xsp:logic>
    <xsl:apply-templates/>
  </xsp:page>
</xsl:template>
. . .
<xsl:template match="hit-count">
  <xsp:expr>hitCount()</xsp:expr>
</xsl:template>
. . . 
</xsl:stylesheet>

Mime
View raw message