0

I have this thymeleaf template and its an email template : https://jsfiddle.net/7dj1ekv8/

Data from the database that I am able to pull successfully using spring data JPA:

enter image description here

I am pulling data from oracle database using below code. I then 'setProps' for the mail and I am able to pull data successfully and show in the email. For eaxmple, I am able to pull employee name using th:text ="emloyeeNameIstRow" :

public void dataMapperSecond(Mail mail) throws MessagingException, IOException {

    Iterable<Employee> employeeDetails = RepositoryObj.findAll();
    for (Employee fetcher : employeeDetails) {
        System.out.println(fetcher.getID());
    }
    

    List<Employee> fetcherByAsList = RepositoryObj.findAll();

    String appName = fetcherByAsList.get(0).getemployeeName();
    System.out.println("The name of the app is : "+employeeName);
    
            
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("AlldataAsList", fetcherByAsList);
    model.put("emloyeeNameIstRow", employeeName);
    model.put("type", "TRANSACTIONAL");
    mail.setProps(model);
    System.out.println("data from the hashmap from data Mapper second:" + model);
    
    emailService.sendEmail(mail);
    log.info("END... Sending Inlined CSS Email with dynamic data");

}

My question :

In this(https://jsfiddle.net/7dj1ekv8/) thymeleaf template, Rather than pulling data for each data cell, how can I pull data all at once and loop to show the data in the thymeleaf template for each row. I want the expand icon i.e. ">" from first row of the thymeleaf to be visible after pulling the data as its clickable. Thanks in advance.

jane
  • 211
  • 9
  • 30
  • Are you asking about [how to iterate in Thymeleaf](https://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf#iteration)? Take a look at `th:each`. You already have `model.put("AlldataAsList", fetcherByAsList)` - so you should be able to use something like ``. Personally I would rename your Java object from `fetcherByAsList` to `employees`, since it is a list of employees. And I would use `"employees"` instead of `"AlldataAsList"`, also, for consistency. – andrewJames Oct 11 '22 at 16:01

0 Answers0