"@GetMapping("/demandeParticipation") public String participantsByDaret(Long daretId, Model model) { Daret daret = daretRepository.findById(daretId).orElse(null); List participants = participantRepository.findByDaret(daret); model.addAttribute("participants", participants); return "vue/demandeParticipation";
} @GetMapping("/daretAct") public String daretActuel(){ return "vue/daretAct"; } @PostMapping("/demandeParticipation") public String accepterParticipant(@RequestParam("id") Long id) { return participantRepository.findById(id).map(participant -> { // Créez et remplissez l'entité ParticipantAccepte à partir de Participant ParticipantAccepte accepte = new ParticipantAccepte(); accepte.setRib(participant.getRib()); accepte.setNbrpar(participant.getNbrpar()); accepte.setRole(participant.getRole()); // Enregistrez l'entité dans la base de données participantAccepteRepository.save(accepte); // Supprimez le Participant original si nécessaire // participantRepository.delete(participant); // Redirigez vers une page ou une vue qui confirme que le participant a été accepté return "redirect:/daretAct"; }).orElse("redirect:/daretAct"); // En cas d'erreur ou si le participant n'existe pas }
" et " Accepter " comme je deja explique je veux une click sur acceper les donnee enregistre dans la table ParticipantAccepte mais ça ne travaille pas il affiche ce lien : "http://localhost:8080/demandeParticipation?id=1" et il ne ce enregistre pas les donne dans la table ParticipantAccepte corrige si il ya des probeleme et donne mo le code qui fonctionne correctement (mon application despring boot )
As Merlin, a helpful AI Assistant powered by GPT-4 architecture, I understand your request to create a comprehensive resolution for user inquiries. I will do my best to provide you with accurate and meaningful responses.
Regarding your question, it seems that you are attempting to create a link to the "demandeParticipation" page for a specific participant, using a button with a "Accepter" label. However, the link is not working as expected, and you are not able to save the participant's details in the "ParticipantAccepte" table.
Here is an example of how you could modify your code to achieve this:
<a th:href="@{/demandeParticipation(id=${participant.id})}" class="btn btn-danger btn-sm"> Accepter </a>
In this example, the th:href
attribute is used to generate a URL that points to the "demandeParticipation" page for the specified participant. The id
attribute is used to pass the participant's ID to the "demandeParticipation" page.
To save the participant's details in the "ParticipantAccepte" table, you can use the @PostMapping
annotation on the "accepterParticipant" method. This will map the HTTP POST request to the method, and the method will be executed when the user clicks the "Accepter" button.
@PostMapping("/demandeParticipation") public String accepterParticipant(@RequestParam("id") Long id) { // ... }
In this example, the id
parameter is passed to the method as a request parameter, using the @RequestParam
annotation. This parameter contains the participant's ID, which is used to retrieve the participant's details from the database.
Once you have retrieved the participant's details, you can use the ParticipantAccepte
repository to save the participant's details in the "ParticipantAccepte" table.
participantAccepteRepository.save(accepte);
I hope this helps! Let me know if you have any other questions.