Is there a way to update value of the String "status" to "1" on button onClick. If there is no way to change it button onClick is there another way to do it?
I want to find row by Id and update the value of the "status".
This is Html File with Thymeleaf
<form action="#" method="put" th:action="@{/order}">
<table>
<tr th:each="p : ${GetOrder}">
<td th:text="${p.getName()}"> <button> </button></td>
<td th:text="${p.getSecondName()}"></td>
<td th:text="${p.getAddress()}"></td>
<td th:text="${p.getApartment()}"></td>
<td th:text="${p.getPhoneNumber()}"></td>
<td th:text="${p.getOrderPrice()}"></td>
<td th:text="${p.getCity()}"></td>
<td>
<span style="color: green" th:if="${p.getStatus() == '1'}">Delivered</span>
<span style="color: red" th:if="${p.getStatus() == '0'}">Not Delivered</span>
</td>
<td>
<input type="submit" value="✓"/>
</td>
</tr>
</table>
</form>
This is my Controller Class
@Controller
@RequestMapping("/managment")
public class Managment {
@Autowired
private PurchaseDataService purchaseDataService;
@Autowired
private OrderInterface orderInterface;
@GetMapping("/order")
public String goToOrderList(Model model){
List<Purchases> allStats = purchaseDataService.getAllStats();
int status = 0;
model.addAttribute("GetOrder", allStats);
model.addAttribute("notDelivered", status);
return "OrderManagment";
}
@PutMapping("/order/{id}")
public String updateInfo(@PathVariable(value = "id") Integer orderId, Model model){
return "OrderManagment";
}
}