Created
June 9, 2011 23:52
-
-
Save shenie/1018017 to your computer and use it in GitHub Desktop.
How to use Category in gsp without calling "use" in the .gsp itself
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
class MyGrailsViewResolver extends GrailsViewResolver { | |
@Override | |
protected View loadView(String viewName, Locale locale) { | |
new MyView(super.loadView(viewName, locale)) | |
} | |
static class MyView implements View { | |
def View view | |
MyView(View view) { | |
this.view = view | |
} | |
String getContentType() { | |
view.getContentType() | |
} | |
void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) { | |
if (model.categories) { | |
use(model.remove('categories')) { | |
view.render model, request, response | |
} | |
} else { | |
view.render model, request, response | |
} | |
} | |
} | |
} |
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
jspViewResolver(MyGrailsViewResolver) { bean -> | |
bean.lazyInit = true | |
viewClass = JstlView | |
prefix = GrailsApplicationAttributes.PATH_TO_VIEWS | |
suffix = ".jsp" | |
templateEngine = ref("groovyPagesTemplateEngine") | |
if (true || developmentMode) { | |
resourceLoader = ref("groovyPageResourceLoader") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment