Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15064

Support i18n and nested template loading in ScriptTemplateView render function


    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: None
    • Fix Version/s: 5.0 M5
    • Component/s: Web
    • Labels:
    • Last commented by a User:


      The render function called by ScriptTemplateView has currently 3 parameters provided:

      • String template: the content of the template resource
      • Map<String, Object>: the model to use to render the view
      • String url: the url of the 2 view

      To achieve i18n support for messages and nested template loading, we need to provide these additional informations:

      • a ResourceBundleMessageSource instance (or the ApplicationContext that allows to retrieve it)
      • the view Locale
      • a Function<String, String> that allows the render function to call ScriptTemplateView#getTemplate(String)

      I see mainly 2 ways to support that:

      1) We could be possible leverage setExposeContextBeansAsAttributes() or setExposedContextBeanNames() to access to context beans and expose them via model attributes.

      2) We could transform the 3rd parameter passed to the script function (currently String url) to RenderingContext that would contains String url, Locale locale, ResourceBundleMessageSource messageSource and Function<String, String> templateLoader properties. This would be a breaking change for people using `url` but ScriptTemplateView is a rather feature, and url is not widely used, so I consider this as an option in order to be consistent and provide such flexible mechanism for further needs + it provides these properties in a type-safe way which would be valuable for Kotlin JSR-223 support.

        Issue Links



            • Assignee:
              sdeleuze Sébastien Deleuze
              sdeleuze Sébastien Deleuze
              Last updater:
              Sébastien Deleuze
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created:
                Days since last comment:
                1 year, 8 weeks, 3 days ago