Skip to content
a groovy breadcrumbs for grails
Groovy Java
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This plugin gives you an Breadcrumb based on a definition of the navigation structure (implementation of a "menuDefinitionService" service). A simple breadcrumb editable and robust. the construction of the breadcrumb is based on the couple action / controller. An annotation allows you to change the breadcrumb. Very flexible and easy to implement.


compile ":groovy-breadcrumbs-plugin:1.0.2"


The breadcrumbs plugin is based on a MenuDefinitionService is provided by the application. So let's go create the service

Run create-service MenuDefinitionService

In MenuDefinitionService create a method called loadMenuDefinition


class MenuDefinitionService  {

    static transactional = false

    static scope = "session"

    static proxy = true

    def loadMenuDefinition() {
        def menus = []

        menus << new MenuItem(name : "page-one", message:"", controller: "BreadCrumbsDemo", action: "pageOne")
        MenuItem menuThreeTwo = new MenuItem(name : "page-two-", message:"page.two.demo", controller: "BreadCrumbsDemo", action:"pageThreeTwo")
        menuThreeTwo << new MenuItem(name : "", message:"", controller: "BreadCrumbsDemo", action:"pageThreeTwoOne")
        menuThreeTwo << new MenuItem(name : "page-two.two", message:"pagetwo.two.demo", controller: "BreadCrumbsDemo", action:"pageThreeTwoTwo")
        menus << menuThreeTwo


You can define as many levels that you want !!!

Just define the message in

like page.two.demo=pageTwo

Declare Service MenuDefinitionService as proxy in resources.groovy

beans = {
    menuDefinitionServiceProxy(org.springframework.aop.scope.ScopedProxyFactoryBean) {
        targetBeanName = 'menuDefinitionService'
        proxyTargetClass = true

Now the end, for define the divider of breadcrumbs

add grails configuration in config.groovy

breadcrumbs.divider = "&gt;"

You can define all > < / - ... divider that you want

You can also define html character like &gt; or &lt; or &yen; if you want :)

Adding the taglib in your layout

<crumbs:breadcrumbs />

Using BreadCrumbs Annotation

To redefine breadcrumb use @BreadCrumbs

The breadcrumb can be reset by three ways

  • static
  • session
  • request

Example with static scope

@BreadCrumbs (scope = BreadCrumbsScopeEnum.STATIC, actionName = "actionName", ControllerName = "ControllerName")
def controllerMethod() {

Example with request scope

@BreadCrumbs (scope = BreadCrumbsScopeEnum.REQUEST, actionName = "actionName", ControllerName = "ControllerName")
def controllerMethod() {

Example with session scope

@BreadCrumbs (scope = BreadCrumbsScopeEnum.SESSION)
def controllerMethod() {

    breadCrumbsService.pushActionInSession ("actionName")
    and / or
    breadCrumbsService.pushControllerInSession ("controllerName")

activate clickable Mode


Configure Home Item


Two mode are possible

mode image


mode text


Add a getHomeItem() in MenuDefinitionService

Example for image mode

def getHomeItem(){
    def message = "breadcrumbs/menu_home.png"
    def home  = new MenuItem(name:"page-home", message: message);

Or for message mode

def getHomeItem(){
    def home  = new MenuItem(name:"page-home", message: "message key");

for style

define a css for



.breadcrumb > li

and for active item

.breadcrumb > li > .active

Thank to

laurent guerin

Something went wrong with that request. Please try again.