Created
May 25, 2012 00:40
-
-
Save founddrama/2785105 to your computer and use it in GitHub Desktop.
Why would the service be null?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.myexample.plugin | |
class MyExampleService { | |
Map doMunge(Map m) { | |
// do stuff to 'm' | |
return m | |
} | |
} | |
/****************************** BREAK: NEXT FILE ******************************/ | |
package net.myexample.plugin | |
class MyTagLib { | |
static namespace = 'p' | |
def myExampleService | |
def tag = { attrs, body -> | |
def m = doMungeAndFilter(attrs.remove('m')) | |
out << g.render(template: '/template', plugin: 'my-example-plugin', model: m) | |
} | |
Map doMungeAndFilter(def m) { | |
def mm = myExampleService.doMunge(m) | |
// do stuff to 'm' | |
return mm | |
} | |
} | |
/****************************** BREAK: NEXT FILE ******************************/ | |
package net.myexample.app | |
import net.myexample.plugin.MyExampleService | |
class MyExampleService extends net.myexample.plugin.MyExampleService { | |
def doMunge(def m) { | |
def mm = super.doMunge(m) | |
// do more stuff to 'mm' | |
return mm | |
} | |
} | |
/****************************** BREAK: NEXT FILE ******************************/ | |
package net.myexample.app | |
import net.myexample.plugin.MyTagLib | |
class MyTagLib extends net.myexample.plugin.MyTagLib { | |
static namespace = 'a' | |
def myExampleService | |
def tag = { attrs, body -> | |
def m = doMungeAndFilter(attrs.remove('m')) | |
out << g.render(template: '/template', plugin: 'my-example-plugin', model: m) | |
} | |
Map doMungeAndFilter(def m) { | |
def mm = super.doMungeAndFilter(m) | |
// do more stuff to 'mm' | |
return mm | |
} | |
} | |
/** | |
* But we get an exception that cites that it cannot call 'doMunge' on a null | |
* object -- which could only be 'myExampleService' | |
*/ |
Author
founddrama
commented
May 25, 2012
- http://notundefined.tumblr.com/post/23704665970/a-grails-question-why-would-this-service-be-null
- http://stackoverflow.com/questions/10747240/grails-why-would-this-service-class-be-null
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment