I want to access the values of the messages.properties but concatenate some value obtained from javascript to it. I am trying to do something like this:
<script th:inline="javascript">
var identificationTypeId = 1;
var identificationTypeValue = [[#{identificationType.identificationTypeId}]];
</script>
I have in mesagges.properties this:enter code here
identificationType.1=Passport
I appreciate the help
You can't. Thymeleaf doesn't have access to client side JavaScript variables.
Alternatives might include:
Putting all the messages you need available into your JavaScript and accessing it with JavaScript. Something like this for example:
var messages = [];
messages[0] = /*[[#{identificationType.0}]]*/ '';
messages[1] = /*[[#{identificationType.1}]]*/ '';
messages[2] = /*[[#{identificationType.2}]]*/ '';
var identificationTypeId = 1;
var identificationTypeValue = messages[identificationTypeId];
Using an ajax call to retrieve the message.