Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

369
Views
How to access messages.properties with thymeleaf from javascript, but using variables defined in javascript

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

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't. Thymeleaf doesn't have access to client side JavaScript variables.

Alternatives might include:

  1. 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];
    
  2. Using an ajax call to retrieve the message.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!