There are Three classes
public Class Port{
private String portname;
// with getters and setters
}
public Class Application{
private String appName;
private List<Port> ports= new ArrayList<Port>();
// with getters and setters
}
public Class Service{
private String serviceName;
private List<Application> apps= new ArrayList<Application>();
// with getters and setters
}
Below snippet is part of the Thymeleaf HTML code to iterate through the fields.
<form action="#" th:action="@{/processWrapper}" th:object="${service}" method="post">
<table>
<div th:each="app, stat : *{apps}">
<tr>
<td><input type="text" th:field="*{apps[__${stat.index}__].appName}" th:name="|apps[${stat.index}]|" /></td>
<div th:each="port, stat1 : *{app.ports}">
<td><input type="text" th:field="*{app.ports[__${stat1.index}__].portname}" th:name="|app.ports[${stat1.index}]|" /></td>
</div>
</div></table></form>
Why is it not working?I get the error message:
Property or field 'ports' cannot be found on object of type 'service' maybe not public?
Servicehave a property calledports? Secondly, you typically makepublicandclasslower case.