You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am using Spring Mobile with Thymeleaf and it is working well. One thing I would like to be able to do is to set the viewResolver to fallback to the the desktop template if a mobile template is not found.
Spring Mobile's LiteDeviceDelegatingViewResolver ( org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver ) has the option to setEnableFallback( true ), which means before it calls to it's delegating viewResolver ( in my case the AjaxThymeleafViewResolver) with the resolveViewName method it adds a mobile prefix to the template name ( say "mobile/" ), and if resolveViewName returns null, it will try again without the mobile prefix. The Javadoc reads:
Enables support for fallback resolution, meaning if the adjusted view name cannot be resolved, and attempt will be made to resolve the original view name. This may be helpful in situations where not all views within a web site have device specific implementations.
Note: fallback resolution will only work when delegating to a view resolver which returns null from resolveViewName(String, Locale) if it cannot resolve a view. For example, InternalResourceViewResolver never returns null, so fallback resolution will not be available.
The reason seems to be that it allows for the flexibility where templates are located, etc.
The solution I was thinking of to allow for this functionality was that suggested in the last article (at the bottom of this one: http://forum.thymeleaf.org/Chaining-view-resolvers-td3295026.html ) of overriding the canHandle method of a the ThymeleafViewResolver to check if the template actually exists. Has any better solution been used or suggested? Are there any unintended side effects this solution could cause?
The text was updated successfully, but these errors were encountered:
Hello, I am using Spring Mobile with Thymeleaf and it is working well. One thing I would like to be able to do is to set the viewResolver to fallback to the the desktop template if a mobile template is not found.
Spring Mobile's LiteDeviceDelegatingViewResolver ( org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver ) has the option to setEnableFallback( true ), which means before it calls to it's delegating viewResolver ( in my case the AjaxThymeleafViewResolver) with the resolveViewName method it adds a mobile prefix to the template name ( say "mobile/" ), and if resolveViewName returns null, it will try again without the mobile prefix. The Javadoc reads:
My understanding of Thymeleaf's viewResolver is that it does not check if the template actually exists during the resolveViewName step after reading this: http://forum.thymeleaf.org/Chaining-view-resolvers-td3295026.html
The reason seems to be that it allows for the flexibility where templates are located, etc.
The solution I was thinking of to allow for this functionality was that suggested in the last article (at the bottom of this one: http://forum.thymeleaf.org/Chaining-view-resolvers-td3295026.html ) of overriding the canHandle method of a the ThymeleafViewResolver to check if the template actually exists. Has any better solution been used or suggested? Are there any unintended side effects this solution could cause?
The text was updated successfully, but these errors were encountered: