Uploaded image for project: 'Struts 1'
  1. Struts 1
  2. STR-2655

new validate-method for custom validation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.2.8
    • None
    • Extras
    • None
    • Operating System: other
      Platform: All
    • 37578

    Description

      in my current project i have forms, which need multiple form-validation
      depending on the users input. since in the present implementation i can only
      validate the form with one validator-key i suggest to add a new actionform-
      method which allows to run a validation with a given validator-key provided by
      the application. heres my implementation:
      public class DynaValidatorWithFormKeyForm extends DynaValidatorForm {
      ...
      public ActionErrors validate(String validationKey, ActionMapping mapping,
      HttpServletRequest request) {
      if (log.isDebugEnabled())
      log.debug("executing validate()");

      final ServletContext application = getServlet().getServletContext();
      final ActionErrors errors = new ActionErrors();
      final Validator validator = Resources.initValidator(validationKey,
      this, application, request, errors, page);
      try

      { validatorResults = validator.validate(); }

      catch (ValidatorException e)

      { log.error(e.getMessage(), e); }

      return errors;
      }

      }

      this allows me to run different validations on one form...

      regards
      chris

      Attachments

        Activity

          People

            Unassigned Unassigned
            chris@cartus.com Christian Cartus
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: