Atozed Forums
Refresh form with new template (Priority support) - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: Refresh form with new template (Priority support) (/thread-3185.html)



Refresh form with new template (Priority support) - valmeras - 04-25-2023

I am using Intraweb 15.3.3 with Rad Studio 10.2.3 (C++ Builder).
I need to be able to change the template loaded by the form each time the user chooses a different language.
The language selection is done through JavaScript : executeAjaxEvent(LanguageCode, null,"ChangeLanguage", true, null, false) which unfortunately does not force a refresh on the form!

ChangeLanguage(TStringList *Parametres)
{
    UnicodeString CodeLanguage = Parametres->Values["Code"];
     IWTemplateProcessorHTML1->Templates->Default = "myTemplate-" + CodeLanguage + ".html";
}

IWForm->AsyncReload() works but it prompts a message to the user which is a problem!

So, how can I force a refresh on the form when a new template is loaded without any message prompted to the user? Or another way to load a new template with form refresh?


RE: Refresh form with new template (Priority support) - Jose Nilton Pace - 04-26-2023

Try clear template cache before:
TIWTemplateCache.Instance.ClearCache;


RE: Refresh form with new template (Priority support) - valmeras - 04-27-2023

This does not resolve the problem.
The issue is not that the page is cached. The problem is that the page does not refresh to reflect the changes!


RE: Refresh form with new template (Priority support) - valmeras - 04-28-2023

I found a solution which works!
I am posting it here because I think it may help other developers.
The link to run the Ajax function to switch the template is written like that:

<a href="#" onclick="JsFunction()">
The href="#" links to the current page. But if you remove # and write it like that:

<a href="" onclick="JsFunction()">

It refreshes the page without prompting any message!