spring-form

Spring MVC Form: data binding of a list of abstract class

无人久伴 提交于 2019-12-10 19:04:59
问题 I've inherited some code that I need add functionality to and it involves a program built on Spring and Spring Form with a list and binding abstract elements So we have an abstract class like the following public abstract class A { private int id; private String name; private int type; ....getters and setters below } And a few implementations such as public class AImplOne extends A { private String text; ...getters, setters etc } public class AImplTwo extends A { private int mediaID; ..

How correctly use the Spring MVC <form:select> tag to show the value of a specific object field into a collection?

心已入冬 提交于 2019-12-10 18:42:25
问题 I am pretty new in Spring MVC and I have some difficulties to understand how exactly works the tag. So I have the following situation. Into a controller I have this method: @RequestMapping(value = "/consultazioneMinisteriale", method = RequestMethod.GET) public String consultazione(Locale locale, Model model) { List<Twb1012Regione> listaRegioni = geograficaService.getListaRegioni(); System.out.println("Numero regioni: " + listaRegioni.size()); model.addAttribute("listaRegioni", listaRegioni);

Posting a complete model object to the controller when only few attributes are used in a form

≡放荡痞女 提交于 2019-12-08 12:22:49
问题 I've read somewhere that for spring mvc, it is a expected behavior to get back NULL in case a form does not contain all the attributes of the model object set by the @ModelAttribute annotiation. S how can I use forms that don't have all the fields of the model object and still recieve the whole but updated object back to the post method of the controller. A short example code of my intention: Part of the controller: .... @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET) public

Spring form:input for number

≯℡__Kan透↙ 提交于 2019-12-06 23:45:34
问题 I am using Spring's form:input as below : <form:input type="number" .....> in my jsp but when I check the html that is rendered on the browser it shows like : type="number" type="text" i.e., two type attributes are generated in the html. On the other hand, if I check using inspect element option in the browser, it shows correct - only type="number" as expected. Edit - My Question: Why am I getting two type attributes in generated html ( type="number" type="text" ) ? How to get it resolved?

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'category' available as request attribute

耗尽温柔 提交于 2019-11-28 10:20:58
I looked almost all answers related this problem on the web but could not figure out the problem in my code. Here is my JSP page. <form:form method="POST" commandName="category" modelAttribute="category" action="search_category"> <form:input path="category_name" /> <input type="submit" value="Submit"> </form:form> When I delete <form:input path="category_name" /> It works fine. I can communicate with my controller. So the problem is related to this line. @Controller public class SearchCategory { @Autowired private CategoryService categoryService; @RequestMapping(value = "/search_category",

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'category' available as request attribute

主宰稳场 提交于 2019-11-27 05:52:58
问题 I looked almost all answers related this problem on the web but could not figure out the problem in my code. Here is my JSP page. <form:form method="POST" commandName="category" modelAttribute="category" action="search_category"> <form:input path="category_name" /> <input type="submit" value="Submit"> </form:form> When I delete <form:input path="category_name" /> It works fine. I can communicate with my controller. So the problem is related to this line. @Controller public class