est-ce possible? Je fais essentiellement une application web Spring CRUD en utilisant la classe MultiActionController et je voudrais que mes formulaires soient validés. J'ai déjà utilisé SimpleUrlController et valang fonctionne parfaitement.appel valang validateur dans MultiActionController ModelAndView méthode ... possible? Comment?
3
A
Répondre
0
Selon MultiActionControlller API
Tenir compte d'une utilisation directe ServletRequestDataBinder dans votre méthode de commande, au lieu de compter sur un argument de commande déclarée. Cela permet un contrôle total sur l'ensemble de la configuration et de l'utilisation du classeur, Y COMPRIS L'INVOCATION DES VALIDATEURS et l'ÉVALUATION SUBSÉQUENTE des erreurs de liaison/validation.
, vous pouvez utiliser
public class AddMultiActionController extends MultiActionController {
public AddMultiActionController() {
// Set up Valang according to your business requirement
// You can use xml settings instead
setValidators(new Validator [] {new CommandValidator(), new AnotherCommandValidator()});
}
public ModelAndView addCommand(HttpServletRequest request, HttpServletResponse response) throws Exception {
Command command = new Command();
// createBinder is a MultiActionController method
ServletRequestDataBinder binder = createBinder(request, command);
// Sets up any custom editor if necessary
binder.registerCustomEditor(...);
binder.bind(command);
return (!(binder.getErrors().hasErrors())) ? new ModelAndView("success") : new ModelAndView("failure");
}
// similar approach as shown above
public ModelAndView addAnotherCommand(HttpServletRequest request, HttpServletResponse response) throws Exception {
AnotherCommand anotherCommand = new AnotherCommand();
...
}
}
salutations,
Questions connexes
- 1. Resolve pagenotfound avec ressort MultiActionController
- 2. Rhino Mocks: Comment simuler un appel de méthode dans un appel de méthode?
- 3. Comment intercepter un appel de méthode dans Boo?
- 4. Problème avec ModelAndView et ModelMap dans AnnotationController, Springframework
- 5. Gamme validateur
- 6. Comment remplacer un objet linq d'un appel de méthode
- 7. Appel d'une méthode avec un SoapExtensionAttribute
- 8. Comment déléguer un appel de méthode à un autre thread?
- 9. ASP.Net ScriptControl - Appel d'une méthode d'un autre
- 10. appel nom de la méthode contenue dans une chaîne
- 11. C++ Appel de méthode de classe parent
- 12. Comment puis-je tester une méthode contenant un appel asynchrone?
- 13. Validateur WSDL
- 14. appel à une méthode ne retourne jamais
- 15. UrlHelper méthode d'extension appel codé non exécuté
- 16. appel de méthode COM retourne Catastrophic Échec
- 17. Appel d'une méthode lorsque UITabBar est sélectionné?
- 18. Appel de méthode de redirection dans le délégué
- 19. NullPointerException sur appel de méthode request.getHeaderNames dans websphere
- 20. Appel à la méthode non définie dans facebook appel à publishUserAction
- 21. Comment localiser les messages du validateur dans flex?
- 22. Comment utiliser le validateur dans ce cas est ASP.NET?
- 23. Comment créer validateur personnalisé dans Asp.net en utilisant ActiveRecord
- 24. jquery validateur addmethod message personnalisé
- 25. Est-il possible d'obtenir la méthode de référence dans VB.NET?
- 26. Email validateur SMTP
- 27. Validateur CSS - Ruby
- 28. JQuery CreditCard validateur
- 29. iphone sdk - appel d'une méthode de viewController de superview
- 30. Appel d'une méthode de classe avec jQuery AJAX?