Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-5046

Validation framework won't work when running a method named input() in an Action class

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 2.3.37
    • None
    • Core Actions
    • 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;
          }	    
      }
      

       

       

       

       

       

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            Ivanhanks Ivan Shih
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment