Package com.opensymphony.xwork2

Examples of com.opensymphony.xwork2.ActionSupport


    logger.debug("convertToString(Map=[{}], Object=[{}]) - start", map, obj);
   
    String res = obj != null ? obj.toString() : StringUtils.EMPTY;
    if (obj != null && obj instanceof BigDecimal) {
     
      ActionSupport action =
        (ActionSupport) ActionContext.getContext().getActionInvocation().getAction();

      String mask = this.getMask(action);
      DecimalFormat nf = new DecimalFormat(mask);
      res = nf.format((BigDecimal) obj);
View Full Code Here


    Date res = null;
    String mask = null;
    if (StringUtils.isNotEmpty(as[0])) {
      try {
        ActionSupport action =
          (ActionSupport) ActionContext.getContext().getActionInvocation().getAction();

        // najpierw RegEx
        String regEx = this.getRegEx(action);
        if (StringUtils.isNotEmpty(regEx)) {
View Full Code Here

    }
   
    String res = obj != null ? obj.toString() : StringUtils.EMPTY;
    if (obj != null && obj instanceof Date) {
     
      ActionSupport action =
        (ActionSupport) ActionContext.getContext().getActionInvocation().getAction();

      String mask = this.getMask(action);
      DateFormat df = new SimpleDateFormat(mask);
      res = df.format((Date) obj);
View Full Code Here

        assertFalse(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

        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);
        valueStack.pop();

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

        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

        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

        ActionMessage err2 = new ActionMessage("error2", new Integer(1));
        ActionErrors errors = new ActionErrors();
        errors.add(errors.GLOBAL_MESSAGE, err1);
        errors.add("foo", err2);

        ActionSupport action = new ActionSupport();
        factory.convertErrors(errors, action);

        assertTrue(1 == action.getActionErrors().size());
        assertTrue(1 == action.getFieldErrors().size());
    }
View Full Code Here

            OgnlValueStack vs = new OgnlValueStack();
            vs.getContext().putAll(Dispatcher.getInstance().createContextMap(req, res, null, servletContext));
            ctx = new ActionContext(vs.getContext());
            if (ctx.getActionInvocation() == null) {
                // put in a dummy ActionSupport so basic functionality still works
                ActionSupport action = new ActionSupport();
                vs.push(action);
                ctx.setActionInvocation(new DummyActionInvocation(action));
            }
        }
View Full Code Here

    public void testEmptyValuesDoNotSetFieldErrors() throws Exception {
        conversionErrors.put("foo", new Long(123));
        conversionErrors.put("bar", "");
        conversionErrors.put("baz", new String[]{""});

        ActionSupport action = new ActionSupport();
        mockInvocation.expectAndReturn("getAction", action);
        stack.push(action);
        mockInvocation.matchAndReturn("getAction",action);
        assertNull(action.getFieldErrors().get("foo"));
        assertNull(action.getFieldErrors().get("bar"));
        assertNull(action.getFieldErrors().get("baz"));
        interceptor.intercept(invocation);
        assertTrue(action.hasFieldErrors());
        assertNotNull(action.getFieldErrors().get("foo"));
        assertNull(action.getFieldErrors().get("bar"));
        assertNull(action.getFieldErrors().get("baz"));
    }
View Full Code Here

TOP

Related Classes of com.opensymphony.xwork2.ActionSupport

Copyright © 2018 www.massapicom. 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.