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

Support i18n and nested template loading in ScriptTemplateView render function

    Details

    • 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:
      true

      Description

      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

          Activity

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open In Progress In Progress
          21h 34m 1 Sébastien Deleuze 29/Dec/16 3:53 PM
          In Progress In Progress Resolved Resolved
          27d 32m 1 Sébastien Deleuze 25/Jan/17 4:25 PM
          Resolved Resolved Closed Closed
          28d 17h 3m 1 Stéphane Nicoll 23/Feb/17 9:29 AM

            People

            • Assignee:
              sdeleuze Sébastien Deleuze
              Reporter:
              sdeleuze Sébastien Deleuze
              Last updater:
              Stéphane Nicoll
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                42 weeks, 4 days ago