-
Notifications
You must be signed in to change notification settings - Fork 1
Improve the way multi-templating works #1
Description
Problem
Hi-Framework currently does not allow a user to use the same app in two tabs that are displaying views in different templates, because when you reload the page, it will automatically apply the last template that was set.
Solution
Stop saving the current template in the user's HTTP session.
Issues create by solution
Set template
When a template is set using FrontEnd.setTemplate, the new template's name is saved in the user's session and the page is automatically reloaded. When the page is reloaded, Hi-Framework applies the template that the HTTP session indicates. The problem is that the template name will no longer be in the HTTP session. How is Hi-Framework going to know the template to apply?
Set language
When the language is changed using I18nRuntime.setLanguage the page is also reloaded. The problem is that, when the page is reloaded, the Framework needs again to know which template should be applied.
Template controllers
When the page is loaded, the hi-es5.js script is loaded along with the controller of the current template. If the current template will no longer be in the user's HTTP session, how is the framework supposed to know which template controller it should include in hi-es5.js?
Smart caching
When smart-caching is applied on templates, the hi-es5.js token is replaced by hi-es5-template-name-deployId.js. The template-name token comes from the value in the user's HTTP session. That token tells Hi-Framework the template controller that it should include in the Hi script. Again, were is that token going to come from now?
Patching issues created by solution
- Pass the current template name as an HTTP header on every redirect and frontier request (Ajax)
- Look for a GET parameter name $set-template = "template-name" when the framework receives a non Ajax MVC Request. If the parameter is not found, assume the default template.
- When reloading the page because of a FrontEnd.setTemplate or because of I18nRuntime.setLanguage invocation, make sure the $set-template GET parameter is present in browser URL.
- When smart-caching is disabled, Hi-Framework will automatically replace the hi-es5.js token by hi-es5-template-name.js so that the server can now which template controller it should include in the Hi script.
Are there changes that affect app developers?
Yes. the FrontEnd.getTemplate() method will be deprecated and replaced with RequestContext.getTemplate()