Announcing the “Navigation” Plugin for Grails

Posted by: on Jan 27, 2009 | 17 Comments

Another plugin release… this time thanks to help from Andreas Arledal on the CSS front.

The Navigation Plugin gives you site navigation menus by convention. You just define a property in your controllers to determine what actions are shown and in what groups.

Full docs here

There is even a default styling of neutral “silver” buttons that you can use, or override the CSS easily, or use tags to render the items any way you like.

Part of the motivation for this is that if we can establish a “de facto” convention for navigation info, then plugins will be able to use it, to have functionality that just automatically “pops up” in your existing application.

Anyway now when you are prototyping your apps you can just add “static navigation = true” to your controllers, and add <nav:render/> to your GSP layout… and away you go!

Enjoy!

17 Comments

  1. Matthew Taylor
    January 27, 2009

    I can’t decide which is better… this Navigation plugin or your recipe for chili paste ;)

    Reply
  2. Marc Palmer
    January 27, 2009

    You’re too kind. I can assure you the chilli paste is better on toast, and the nav plugin helps people get around your sites better than the paste.

    Reply
  3. Dreur
    January 28, 2009

    I prefer the chili paste :)
    Thanks for the plugin seem nice.

    Reply
  4. Martin Flower
    January 28, 2009

    Is this a broken link in the documentation ? (http://www.grails.org/Navigation+Plugin)

    !Picture 1.png!

    Reply
  5. Marc Palmer
    January 29, 2009

    Martin – there is a problem with image upload, so I could not upload the image, so I included it on this blog post for now. I will link to the version on my site for the time being

    Reply
  6. Chris Masters
    January 30, 2009

    Just installed your plugin works great!

    Many thanks – but for those people who cannot get it from plugin list (1.1 beta 2 it didn’t show up…) it is handy to know that

    grails install-plugin http://plugins.grails.org/grails-navigation/tags/RELEASE_1_0/grails-navigation-1.0.zip

    Does the trick.

    Reply
  7. Richard
    February 22, 2009

    Hi

    Great plugin – except I can’t get the auth example to work in 1.0.4

    Any clues? I get an NPE as soon as I try to make the navigation a map instead of an array.. whether i include one or more members as in your example.

    class AuthController {
    static navigation = [
    [group:'userOptions', action:'login', order: 0, isVisible: { session.user == null }]
    ]

    the stack trace includes this

    2009-02-22 22:02:26.208::WARN: Nested in org.springframework.beans.factory.access.BootstrapException: Error executing bootstraps; nested exception is org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NullPointerException:
    java.lang.NullPointerException
    at NavigationService$_registerItem_closure4.doCall(NavigationService.groovy:74)
    at NavigationService.registerItem(NavigationService.groovy:71)
    at NavigationGrailsPlugin$_refreshNavigation_closure7.doCall(NavigationGrailsPlugin.groovy:47)
    at NavigationGrailsPlugin.refreshNavigation(NavigationGrailsPlugin.groovy:40)
    at NavigationGrailsPlugin.this$2$refreshNavigation(NavigationGrailsPlugin.groovy)
    at NavigationGrailsPlugin$_closure4.doCall(NavigationGrailsPlugin.groovy:27)
    at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy:67)
    at RunApp_groovy$_run_closure2_closure7.doCall(RunApp_groovy)
    at Init_groovy$_run_closure6.doCall(Init_groovy:131)
    at RunApp_groovy$_run_closure2.doCall(RunApp_groovy:66)
    at RunApp_groovy$_run_closure2.doCall(RunApp_groovy)
    at RunApp_groovy$_run_closure1.doCall(RunApp_groovy:57)
    at RunApp_groovy$_run_closure1.doCall(RunApp_groovy)
    at gant.Gant.dispatch(Gant.groovy:271)
    at gant.Gant.this$2$dispatch(Gant.groovy)
    at gant.Gant.invokeMethod(Gant.groovy)
    at gant.Gant.processTargets(Gant.groovy:436)
    at gant.Gant.processArgs(Gant.groovy:372)

    Thanks!
    Richard

    Reply
  8. Richard
    February 23, 2009

    OK, after realising I shouldn’t file bugs in blogs, especially after 11pm :) I debugged this and filed

    https://fisheye.codehaus.org/browse/GRAILSPLUGINS-919

    Richard

    Reply
  9. Masih
    March 8, 2009

    Hi Mark,
    Thank you for the Navigation plugin.well done.
    i have been playing with the nav plugin and i came up with some ideas to make it more flexible,
    it is nice to have horizontal or vertical menu option in the plugin, and the sub menu items , i think a simple javascript menu works great on that.
    i am working on it and just wanted to know if you are planning to add more features in navigation plugin
    thanks

    Reply
    • David
      September 12, 2010

      Please let all know when you have the vertical menu done!

      Reply
  10. Scott
    August 19, 2009

    Just trying this out today (1.1). Looks pretty useful. I am wondering if the isVisible closure should be able to access actionName and controllerName, this way it would be possible to add items that only appear on specific pages.

    Cheers,

    Scott

    Reply
  11. Chris
    July 6, 2010

    Hi,

    nice Plugin!!! But one question: How do you render a single Item out of a group?
    I want the Navigation to be in a left Panel, with SubItems directly below the active Item. Thinking about something like that:

    <nav:eachItem group="

    Reply
    • David
      September 13, 2010

      Hi, how far have u gotten with your left panel plan for nav?

      Reply
  12. Martin Gee
    October 3, 2010

    Awesome plugin! What are the futures for this plugin?

    Reply
  13. Nirav Assar
    November 26, 2010

    The navigation plugin you have is fantastic. Thanks for that.

    Reply
  14. Ravi
    July 22, 2011

    Will you be fixing the issues for http://jira.grails.org/browse/GPNAVIGATION or will it have to stay like that?

    Reply
    • Marc Palmer
      July 27, 2011

      I will as soon as I get a chance. I don’t get paid to work on the plugins, and finding time is tricky.

      Reply

Leave a Reply