8.1.1 WebAttributes Trait Example - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 3.0.11
8.1.1 WebAttributes Trait Example
WebAttributes is one of the traits provided by the framework. Any Groovy class may implement this trait to inherit all of the properties and behaviors provided by the trait.// src/main/groovy/demo/Helper.groovy package demoimport grails.web.api.WebAttributesclass Helper implements WebAttributes { List<String> getControllerNames() { // There is no need to pass grailsApplication as an argument // or otherwise inject the grailsApplication property. The // WebAttributes trait provides access to grailsApplication. grailsApplication.getArtefacts('Controller')*.name } }
// src/main/groovy/demo/Helper.groovy package demoimport grails.web.api.WebAttributes import groovy.transform.CompileStatic@CompileStatic class Helper implements WebAttributes { List<String> getControllerNames() { // There is no need to pass grailsApplication as an argument // or otherwise inject the grailsApplication property. The // WebAttributes trait provides access to grailsApplication. grailsApplication.getArtefacts('Controller')*.name } }