Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hashmap Iteration Problem in thymeleaf #284

Open
soumyadip007 opened this issue Jun 10, 2020 · 0 comments
Open

Hashmap Iteration Problem in thymeleaf #284

soumyadip007 opened this issue Jun 10, 2020 · 0 comments

Comments

@soumyadip007
Copy link

Expected Behavior

1
                                     <td>
                                        <input class="form-control" th:field="${person.hm[__${rowStat.index}__].getKey}" th:errorclass="is-invalid"/>
                                   </td>
                                    <td>
                                        <input class="form-control" th:field="${person.hm[__${rowStat.index}__]}" th:errorclass="is-invalid"/>
                                   </td>
                                           <!--    <td>
                                  <div class="btn-group">
                                            <button type="button" name="removeTest" th:value="${rowStat.index}" class="btn btn-outline-danger" data-update-test-url="/removeTest">
                                                <i class="fas fa-trash"></i>
                                            </button>
                                        </div>  
                                    </td> -->  
                                </tr>
                                </tbody>

package com.example.demo.model;

import javax.persistence.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**

  • Created by jjmendoza on 31/8/2018.
    */
    //@entity
    public class Person {

    // @id
    // @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    // @notblank
    private String name;

    // @notblank
    private String lastName;

// @Valid
// @onetomany(cascade = CascadeType.ALL)
// @joincolumn(name = "person_id")
private List contactList = new ArrayList<>();

public List<String> testList = new ArrayList<>();

public HashMap<String,String> hm=new HashMap<String, String>();


public Long getId() {
	return id;
}




public void setId(Long id) {
	this.id = id;
}




public String getName() {
	return name;
}




public void setName(String name) {
	this.name = name;
}




public String getLastName() {
	return lastName;
}




public void setLastName(String lastName) {
	this.lastName = lastName;
}




public List<Contact> getContactList() {
	return contactList;
}




public void setContactList(List<Contact> contactList) {
	this.contactList = contactList;
}




public List<String> getTestList() {
	return testList;
}




public void setTestList(List<String> testList) {
	this.testList = testList;
}




public HashMap<String, String> getHm() {
	return hm;
}




public void setHm(HashMap<String, String> hm) {
	this.hm = hm;
}




@Override
public String toString() {
	
	
	for(Contact s:contactList)
		System.out.println(s.toString());
	
	for(String s:testList)
	System.out .println(s+"1212121212  \n\n");
	
	return "Person [id=" + id + ", name=" + name + ", lastName=" + lastName + ", contactList=" + contactList
			+ ", testList=" + testList + ", hm=" + hm + "]";
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant