struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Lenart (Jira)" <j...@apache.org>
Subject [jira] [Closed] (WW-5046) Validation framework won't work when running a method named input() in an Action class
Date Wed, 13 Nov 2019 06:02:00 GMT

     [ https://issues.apache.org/jira/browse/WW-5046?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Lukasz Lenart closed WW-5046.
-----------------------------
    Resolution: Not A Problem

{{input}} method is treated as a special kind of method, which can be used to handle an input
form, an entry point to gatterhing user's data, That's why it's excluded in the default stack,
see documentation:

https://struts.apache.org/core-developers/validation.html#turning-on-validation
https://github.com/apache/struts/blob/master/core/src/main/resources/struts-default.xml#L331-L333

If you need a different behaviour, please define your own default stack (which is a good practice)
and redefine {{excludeMethods}}. Please notice that this is also by default a global allowed
method:

https://github.com/apache/struts/blob/master/core/src/main/resources/struts-default.xml#L386
https://struts.apache.org/core-developers/action-configuration.html#strict-method-invocation


> Validation framework won't work when running a method named input() in an Action class
> --------------------------------------------------------------------------------------
>
>                 Key: WW-5046
>                 URL: https://issues.apache.org/jira/browse/WW-5046
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.3.37
>         Environment: Windows 10
> Struts 2.3.37
> Eclipse Oxygen
> Tomcat 9.0.24
>            Reporter: Ivan Shih
>            Priority: Major
>              Labels: easyfix
>
> 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() :
> {code:java}
> public class BookAction extends ActionSupport implements ModelDriven<Book> {
>     private Book book = new Book();
>     @Override public Book getModel() {
>         return book; 
>     }
>     public String input() {
>         return SUCCESS;
>     }	    
> }
> {code}
>  Book Class:
> {code:java}
> public class Book {	
>     private String isbn;
>     // get and set method
>     ...
> }
> {code}
>  
> BookAction-validation.xml:
>  
> {code:java}
> <validators>	
>   <validator type="requiredstring">
>     <param name="fieldName">isbn</param>     
>     <message>ISBN is empty!!!</message>
>   </validator>
> </validators>
> {code}
>  
> 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 :
> {code:java}
> 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;
>     }	    
> }
> {code}
>  
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message