1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| public class GestionUtilisateursController extends SimpleFormController {
private Log logger = LogFactory.getLog(GestionUtilisateursController.class);
private DomainService domainService;
private UtilisateurRecherche ur = null;
public void setDomainService(DomainService domainService) {
this.domainService = domainService;
}
@Override
protected Map<String, Object> referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception {
logger.info("referenceData");
HashMap<String, Object> map = new HashMap<String, Object>();
if(this.ur != null){
map.put("utilisateurs", domainService.rechercheUtilisateurs(this.ur));
}else{
map.put("utilisateurs", domainService.getUtilisateurs());
}
return map;
}
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception {
// On stocke les critères de recherche
this.ur = (UtilisateurRecherche)command;
// On redirige l'utilisateur sur la page de gestion des utilisateurs
return new ModelAndView("redirect:/secure/gestion-utilisateurs.html");
}
protected Object formBackingObject(HttpServletRequest request) throws Exception {
if(this.ur != null){
return this.ur;
}
return new UtilisateurRecherche();
}
} |
Partager