Examples of ActionSupport


Examples of com.opensymphony.xwork.ActionSupport

   
    public void destroy() {}
    public void init() {}

    public String intercept(ActionInvocation actionInvocation) throws Exception {
        ActionSupport action = (ActionSupport) actionInvocation.getAction();
        try {
            return actionInvocation.invoke();
        } catch (Exception e) {
            action.addActionError("Error: " + e.getMessage());
            log.error(e.getMessage(), e);
            return Action.ERROR;
        }
    }
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

   
    if (!(action instanceof ActionSupport)) {
      log.warn("Full Hibernate Plugin Validation Allowed only in Actions that 'ISA' ActionSupport");
      return invocation.invoke();
    }
    ActionSupport actionAs = (ActionSupport) action;
    log.debug("Full Hibernate Plugin Validation in "+actionAs.getClass());
   
    Locale clientLocale = actionAs.getLocale();
   
//    List<InvalidValue> invalidValuesFromRequest = new ArrayList<InvalidValue>();
   
    Collection invalidValuesFromRequest = validator.validate(actionAs, clientLocale,getClass().getClassLoader());
    /*
    ResourceBundle clientResourceBundle = ResourceBundle.getBundle("org.hibernate.validator.resources.DefaultValidatorMessages", clientLocale, this.getClass().getClassLoader());
    InputStream stream = getClass().getResourceAsStream("/ValidatorMessages.properties");
    ClassValidator actionValidator = null;
    if (stream!=null) {
      PluginValidatorMessages validatorMessages = new PluginValidatorMessages(stream);
      validatorMessages.setParent(clientResourceBundle);
      actionValidator = new ClassValidator(action.getClass(),validatorMessages);
    } else {
      actionValidator = new ClassValidator(action.getClass(),clientResourceBundle);
    }
   
    // take all errors but discard when the field do not came from the request
    // Only the first validation error by field is used.
    InvalidValue[] invalidValues = actionValidator.getInvalidValues(action);
    List<String> invalidFieldNames = new ArrayList<String>();
    Map parameters = ActionContext.getContext().getParameters();
    for (InvalidValue invalidValue : invalidValues) {
      String fieldFullName = invalidValue.getPropertyPath();
      if (invalidFieldNames.contains(fieldFullName))
        continue;
      if (parameters.containsKey(fieldFullName)) {
        invalidValuesFromRequest.add(invalidValue);
        invalidFieldNames.add(fieldFullName);
      }
    }
    invalidValues=null;
    invalidFieldNames.clear();
    invalidFieldNames=null;
    actionValidator=null;
    */
    if (invalidValuesFromRequest.isEmpty()) {
      log.debug("Full Hibernate Plugin Validation found no erros.");
      actionAs.validate();
      if (actionAs.hasActionErrors() || actionAs.hasFieldErrors()) {
        log.debug("Full Hibernate Plugin found custom validation errors: "+actionAs.getFieldErrors()+" "+actionAs.getActionErrors());
        return actionAs.input();
      }
      else {
        return invocation.invoke();
      }
    } else {
      validator.addFieldErrors(actionAs, invalidValuesFromRequest);
      /*for (InvalidValue invalidValue : invalidValuesFromRequest) {
        StringBuilder sbMessage = new StringBuilder(actionAs.getText(invalidValue.getPropertyPath(),""));
        if (sbMessage.length()>0)
          sbMessage.append(" - ");
        sbMessage.append(actionAs.getText(invalidValue.getMessage()));
        actionAs.addFieldError(invalidValue.getPropertyPath(), sbMessage.toString());
      }*/
      log.debug("Full Hibernate Plugin Validation found "+actionAs.getFieldErrors().size()+" validation Errors.");
      actionAs.validate();
      if (action instanceof Preparable) {
        Method methodPrepare = Preparable.class.getDeclaredMethod("prepare");
        methodPrepare.invoke(action);
      }
      return actionAs.input();
    }

  }
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

public class StrutsResultSupportTest extends StrutsInternalTestCase {


    public void testParse() throws Exception {
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(new ActionSupport() {
            public String getMyLocation() {
                return "ThisIsMyLocation";
            }
        });
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

        EasyMock.verify(mockActionInvocation);
    }

    public void testParseAndEncode() throws Exception {
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(new ActionSupport() {
            public String getMyLocation() {
                return "/myPage?param=value&param1=value1";
            }
        });
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

    }


    public void testNoParseAndEncode() throws Exception {
        ValueStack stack = ActionContext.getContext().getValueStack();
        stack.push(new ActionSupport() {
            public String getMyLocation() {
                return "myLocation.jsp";
            }
        });
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

        assertTrue(verifyEmailValidityWithExpression("tmjee@yahoo.co", "\\b^[a-z]+@[a-z]+(\\.[a-z]+)*\\.com$\\b"));
    }

    protected boolean verifyEmailValidity(final String email) throws Exception {
        ActionSupport action = new ActionSupport() {
            public String getMyEmail() {
                return email;
            }
        };

        EmailValidator validator = new EmailValidator();
        validator.setValidatorContext(new DelegatingValidatorContext(action));
        validator.setFieldName("myEmail");
        validator.setDefaultMessage("invalid email");
        validator.setValueStack(ActionContext.getContext().getValueStack());
        validator.validate(action);

        return (action.getFieldErrors().size() == 0);
    }
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

        return (action.getFieldErrors().size() == 0);
    }

    public boolean verifyEmailValidityWithExpression(final String email, final String expression) throws Exception {
        ActionSupport action = new ActionSupport() {
            public String getMyEmail() {
                return email;
            }

            public String getEmailExpression() {
                return expression;
            }
        };

        EmailValidator validator = new EmailValidator();
        ValueStack valueStack = ActionContext.getContext().getValueStack();
        valueStack.push(action);
        validator.setValueStack(valueStack);

        validator.setValidatorContext(new DelegatingValidatorContext(action));
        validator.setFieldName("myEmail");
        validator.setDefaultMessage("invalid email");
        validator.setRegexExpression("${emailExpression}");

        validator.validate(action);

        return (action.getFieldErrors().size() == 0);
    }
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

        validator = verifyCaseSensitive(false);
        assertFalse(validator.isCaseSensitive());
    }

    private EmailValidator verifyCaseSensitive(final boolean caseSensitive) {
        ActionSupport action = new ActionSupport() {
            public boolean getEmailCaseSensitive() {
                return caseSensitive;
            }
        };
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

        validator = verifyTrim(false);
        assertFalse(validator.isTrimed());
    }

    private EmailValidator verifyTrim(final boolean trim) {
        ActionSupport action = new ActionSupport() {
            public boolean getTrimEmail() {
                return trim;
            }
        };
View Full Code Here

Examples of com.opensymphony.xwork2.ActionSupport

    String[] conversionErrorValue = new String[] { "some value" };
    Map<String, Object> conversionErrors = ActionContext.getContext().getConversionErrors();
    conversionErrors.put("someFieldName", conversionErrorValue);
    conversionErrors.put("xxxsomeFieldName", conversionErrorValue);
   
    action = new ActionSupport();
    validator1 =
      new InternalRepopulateConversionErrorFieldValidatorSupport();
    validator1.setFieldName("someFieldName");
    validator1.setValidatorContext(new DelegatingValidatorContext(action));
   
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.