Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TilesViewResolver to enable fallback if tiles definition does not exist [SPR-5689] #10359

Closed
spring-projects-issues opened this issue Apr 21, 2009 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Apr 21, 2009

Mark Fisher opened SPR-5689 and commented

Currently the typical way of integrating Tiles is to use a TilesView as the 'viewClass' for a UrlBasedViewResolver. Any UrlBasedViewResolver instance will prevent later resolvers in a chain (those with a higher 'order' value) from being invoked at all, because UrlBasedViewResolvers do not return null. In this particular case, the TilesView will be created and returned even if it the 'url' is an invalid tiles definition name.

However, it should be possible to add an earlier check within a TilesViewResolver implementation since the TilesContainer does provide an isValidDefinition(..) method. That way, we could return null and enable fallback to additional ViewResolvers in the chain.

For one thing, this would allow incremental adoption of Tiles within a large application that is currently using JSP via InternalViewResolver (and JstlView).


Issue Links:

2 votes, 2 watchers

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

For a FreemarkerView (and VelocityView) the same feature would be equally useful - if the template doesn't exist, we know that it isn't going to render, so it would be better to resolve to null.

@spring-projects-issues
Copy link
Collaborator Author

Dave Syer commented

Rossen suggested using the viewNames property of the UrlBasedViewResolver. This works up to a point, but isn't really very helpful for less simple use cases (I want to create my views once, and possibly in another JAR file than where the view resolver lives).

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

I've added a general checkResource mechanism to AbstractUrlBasedView and UrlBasedViewResolver, which VelocityView, FreeMarkerView and TilesView support now. Without any special configuration, UrlBasedViewResolvers should return null if the target resource doesn't exist for those now. I've also added a convenience TilesViewResolver, which is just a UrlBasedViewResolver with TilesView as default view class.

However, this hasn't been integration-tested yet. Any volunteers? :-)

Juergen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants