Uploaded image for project: 'XWork'
  1. XWork
  2. XW-1008

Improve ValidatorInterceptor to allow exceptions to invocation

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0.3
    • 1.1, 1.1.1
    • Validators
    • None
    • Windows XP, JDK 1.4.2

    Description

      The ValidationInterceptor gets invoked no matter what. It would be nice if you could specify that it wouldn't be invoked for certain cases. This allows the user to specify less actions in xwork.xml. For example, I don't want to invoke it when users click on Cancel, Delete or when they're first requesting the form. Here's a method from the custom interceptor I wrote.

      protected void before(ActionInvocation invocation) throws Exception {
      Action action = invocation.getAction();
      String context = invocation.getProxy().getActionName();

      final Map parameters = ActionContext.getContext().getParameters();
      // don't validate on cancel, delete or GET
      if (ServletActionContext.getRequest().getMethod().equals("GET")) {
      if (log.isDebugEnabled())

      { log.debug("Cancelling validation, detected GET request"); }

      } else if (parameters.containsKey("cancel") || parameters.containsKey("delete")) {
      if (log.isDebugEnabled())

      { log.debug("Cancelling validation, detected clicking cancel or delete"); }

      } else {
      if (log.isDebugEnabled())

      { log.debug("Validating " + invocation.getProxy().getNamespace() + invocation.getProxy().getActionName() + "."); }

      ActionValidatorManager.validate(action, context);
      }
      }

      I suppose it's easy enough to extend, but I thought this might be a nice feature.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mraible Matt Raible
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: