Envoyer un "model" au controller a partir d'une table
Bonjour,
J'utilise actuellement Spring Portlet MVC. Mon problème ce décompose en 2 parties. J'ai un tableau de patient et je voudrai récupérer le patient se trouvant sur la même ligne que le bouton submit.
Tout d'abord, un exemple de mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<table>
<tbody>
<c:forEach var="patient" items="${patients}">
<tr>
<td>${patient.name}</td>
<td>${patient.surname}</td>
<td>
<portlet:actionURL var="chooseAction">
<portlet:param name="action" value="choose" />
<portlet:property name="patient" value="${patient}" />
</portlet:actionURL>
<form:form action="${chooseAction}">
<input type="submit" value="ok" />
</form:form>
</td>
</tr>
</c:forEach>
</tbody>
</table> |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
@Controller
@RequestMapping("view")
public class PatientsManagementController {
@Autowired
private Service service;
@ModelAttribute("patients")
public List<Patient> getPatients() {
return service.getAllPatients();
}
@RenderMapping
protected String showView() {
return "view";
}
@ActionMapping(params="action=choose")
protected void choosePatient(PortletRequest request) {
Patient patient = (Patient) request.getAttribute("patient");
}
} |
Pour le moment ça ne fonctionne pas, je voudrais pouvoir mettre mon patient dans la PortletRequest au moment du submit. Comment faire?
Deuxièmement, j'aimerai pouvoir supprimer mon bouton et ajouter un onclick sur le <tr>, est-ce possible?
Merci beaucoup pour vos informations,