Grails-Plugin: Counter

Fork me on GitHub

Counter

Grails-Plugin: Manage Counters

Introduction

This plugin manages counters, e.g. you can create a simple access statistic for a website or it can be used as back-end for polling or voting.
Every counter has a name and every increment is logged with date and time. And with the simple tag: <g:counterMonthlyGraph countMonth="6" name="Test" /> you have a statistics report as line graph.

Download

Release 0.1.1 (Source on GitHub)

Installation

grails install-plugin [path_to]/grails-counter-0.1.1.zip

Start your application and navigate to the page http://localhost:8080/[your_app]/counter. You will see simple test page.

Usage

Increment a counter

Increment a counter within a controller action:

def counterService

// Within an action you can increment a counter
counterService.increment(name: "Test")

Increment a counter within a web page (initiated from client side). Insert in the body of the HEAD-Section of your GSP:

<script src="${createLink(action: 'increment', controller: 'counter', params: [name: 'Test'])}" 
           type="text/javascript"></script>

Or increment a counter with AJAX. The following example needs JQuery.

$.get("${createLink(action: 'increment', controller: 'counter')}", {name: 'Test'})

Show the monthly graph

First you have to include some needed Javascript files in the body of the HEAD-Section of your GSP. The Counter-Plugin provides a simple tag for that.

<g:counterRes />

This tag will include some needed Javascript files especially JQuery. If you have already the JQuery included use the attribute omitJQuery to omit it.

<g:counterRes omitJQuery='true' />

And now you can integrate the monthly graph in the BODY-Section of your GSP:

<g:counterMonthlyGraph countMonth="6" name="Test" />

More Documentation

For more documentation download the Source from GitHub and build the documentation with grails doc and open the page [path_to_source]/target/docs/index.html in your browser.

Many Thanks

One thought on “Grails-Plugin: Counter

  1. Pingback: Grails-Plugin “Counter” released | WebApp-Blogger

Comments are closed.