Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
2.3.37
-
None
-
Windows 10
Struts 2.3.37
Eclipse Oxygen
Tomcat 9.0.24
-
Important
Description
When running a method named input() in an Action class, the build-in validation framework won't work, i.e., the validation messages doesn't get displayed, no validation function is performed:
BookAction Class with a method named input() :
public class BookAction extends ActionSupport implements ModelDriven<Book> { private Book book = new Book(); @Override public Book getModel() { return book; } public String input() { return SUCCESS; } }
Book Class:
public class Book { private String isbn; // get and set method ... }
BookAction-validation.xml:
<validators> <validator type="requiredstring"> <param name="fieldName">isbn</param> <message>ISBN is empty!!!</message> </validator> </validators>
Results:
The build-in validation framework won't work, i.e., the validation messages doesn't get displayed, no validation function is performed.
How to Fix:
Changing the method name to inputs() or else in BookAction Class :
public class BookAction extends ActionSupport implements ModelDriven<Book> { private Book book = new Book(); @Override public Book getModel() { return book; } // Changing the method name to inputs() or else fix the issue public String inputs() { return SUCCESS; } }