spring - Change locale (language) but retain form data -
i'm using spring , thymeleaf present form on web-page. user can change language clicking button on page. send get
request same page again, requested locale appended parameter, e.g. <a href="?locale=en_gb">british english</a>
.
i have requirement if user changes languages after filling in of form fields, entered values should maintained.
i guess i'll have post form server, can repopulate form when re-renders page in new language. there standard spring/thymeleaf way this?
i think i've got working using cookielocaleresolver
localeresolver
bean. then, when user clicks on button, set cookie , post form.
<a onclick="document.cookie='mylocalecookie=en_gb'; $('#the-form').submit();>british english</a>
i'd still interested know if there's better or more standard way of doing though.
Comments
Post a Comment