Мне нужно установить флажок внутри таблицы с информацией. У меня есть таблица как так:
<table class="table table-striped" data-toggle="table" data-show-toggle="true" data-classes="table-no-bordered" data-striped="true" data-search="true" data-show-columns="true" data-pagination="true" style="table-layout: fixed;">
<thead>
<th>Carrier Name</th>
<th>Step 1</th>
<th>Step 2</th>
<th>Step 3</th>
<th>Step 4</th>
<th>Step 5</th>
<th>Step 6</th>
<th>Time to Complete</th>
<th>Notes</th>
</thead>
<tbody>
<tr th:each="ma,stat : *{marketAccess}">
<td><p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.parentCompanyCarrier}"></p> </td>
<td><p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.step1}"></p>
<input type="checkbox" th:field="*{marketAccess[__${stat.index}__].step1Completed}" th:value="${step1Completed}"/>
<p style="font-size:12px; display: inline;">Completed?</p><br/>
<!--<td><input type="checkbox" data-toggle="toggle" data-on="Completed" data-off="Not Completed" data-onstyle="success" th:field="*{marketAccess[__${stat.index}__].step1Completed}"/>-->
<!--</td>-->
</td>
<td>
<p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.step2}"></p>
<!--<input type="checkbox" th:field="*{ma.step2Completed}" />-->
</td>
<td><p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.step3}"></p>
</td>
<td><p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.step4}"></p>
</td>
<td><p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.step5}"></p>
</td>
<td><p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.step6}"></p>
</td>
<td><p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.timeToComplete}"></p></td>
<td><p th:text="*{marketAccess[__${stat.index}__].carrierAppointment.notes}"></p></td>
</tr>
</tbody>
</table>
Мне удалось отобразить всю информацию о таблице, пока я не добавил флажок. Я пробовал разные способы. Я пробовал без stat.index, я пробовал ма вместо доступа к рынку ... ничего из этого не работает.
Это ошибка, которую я получаю:
java.lang.IllegalStateException: ни BindingResult, ни простой целевой объект для имени компонента «marketAccess [0]» не доступны в качестве атрибута запроса
Вот мой контроллер:
@RequestMapping("/client/{id}/credentialTracker")
public String getCredTracker(@PathVariable("id") Long id, Model model){
Client client= clientRepository.findById(id);
List<MarketAccess> marketAccess = marketAccessRepository.findByClient(client);
model.addAttribute("client", client);
model.addAttribute("marketAccess", marketAccess);
return "credentialTracker";
}
Любая идея, почему это вызывает эту ошибку и какие шаги я должен предпринять, чтобы исправить это?