Changeset 8 for trunk/grails-app/controllers
- Timestamp:
- Oct 14, 2009, 6:29:37 PM (13 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/BaseController.groovy
r7 r8 1 import org.codehaus.groovy.grails.commons.GrailsApplication 1 2 import grails.util.GrailsUtil 2 3 3 4 /** 4 * DebugController5 * Base Controller 5 6 * @Author Jeroen Wesbeek 6 7 * @Since 20091014 7 8 * @Description 8 9 * 9 * If all controllers extend this debug controller in one piece of code the 10 * behaviour of the other controllers can be -to some extent- manipulated. 10 * Base Controller which provides general functionality 11 11 * 12 12 * Revision information: … … 15 15 * $Date$ 16 16 */ 17 class DebugController {17 class BaseController { 18 18 /** 19 19 * Turn scaffolding on or off … … 22 22 23 23 /** 24 * Render output to the browser, overload this method to suit your needs24 * Render default output to the browser, overload this method to suit your needs 25 25 */ 26 26 def index = { 27 27 render(sprintf("%s @ %s environment :: nothing to see here! :)",this.class.name,GrailsUtil.environment)); 28 28 } 29 30 /** 31 * intercept any method calls in extended classes 32 * @see http://www.grails.org/Controllers+-+Interceptors 33 */ 34 def beforeInterceptor = [action:this.&auth,except:'login'] 35 36 /** 37 * after interception 38 * @see http://www.grails.org/Controllers+-+Interceptors 39 */ 40 def afterInterceptor = { model, modelAndView -> 41 println "Current view is ${modelAndView.viewName}" 42 if(model.someVar) modelAndView.viewName = "/mycontroller/someotherview" 43 println "View is now ${modelAndView.viewName}" 44 } 45 46 /** 47 * authentication method 48 */ 49 def auth() { 50 if(!session.user) { 51 redirect(action:'login') 52 return false 53 } 54 } 55 56 /** 57 * login method 58 */ 59 def login = { 60 // display login page 61 println "render login..."; 62 } 29 63 }
Note: See TracChangeset
for help on using the changeset viewer.