Package com.alibaba.citrus.service.form

Examples of com.alibaba.citrus.service.form.MessageContext


        field2 = (FieldImpl) group.getField("field2");
    }

    @Test
    public void formMessageContext() throws Exception {
        MessageContext formContext = form.getMessageContext();

        assertGenericContext(formContext);
        assertFormContext(formContext);
    }
View Full Code Here


        assertFormContext(formContext);
    }

    @Test
    public void groupMessageContext() throws Exception {
        MessageContext groupContext = group.getMessageContext();
        assertSame(form.getMessageContext(), groupContext.getParentContext());

        assertGenericContext(groupContext);
        assertFormContext(groupContext);
        assertGroupContext(groupContext);
    }
View Full Code Here

        assertGroupContext(groupContext);
    }

    @Test
    public void fieldMessageContext() throws Exception {
        MessageContext fieldContext = field1.getMessageContext();
        assertSame(group.getMessageContext(), fieldContext.getParentContext());

        assertGenericContext(fieldContext);
        assertFormContext(fieldContext);
        assertGroupContext(fieldContext);
        assertFieldContext(fieldContext);
View Full Code Here

        assertFieldContext(fieldContext);
    }

    @Test
    public void validatorMessageContext() throws Exception {
        MessageContext validatorContext = MessageContextFactory.newInstance(field1, new MyValidator(true));

        assertSame(field1.getMessageContext(), validatorContext.getParentContext());
        assertGenericContext(validatorContext);
        assertFormContext(validatorContext);
        assertGroupContext(validatorContext);
        assertFieldContext(validatorContext);
        assertValidatorContext(validatorContext);
View Full Code Here

        return newContext(context, validator, context.getValue());
    }

    /** 创建一个和指定validator相关的context,使用指定的value。 */
    protected final Context newContext(Context context, Validator validator, Object value) {
        MessageContext expressionContext = MessageContextFactory.newInstance(context.getField(), validator);
        expressionContext.copyLocalContext(context.getMessageContext());
        return new ValidatorContextImpl(expressionContext, context.getField(), value);
    }
View Full Code Here

        if (isValid()) {
            boolean found = false;

            for (Validator validator : getFieldConfig().getValidators()) {
                if (isEquals(validator.getId(), id)) {
                    MessageContext expressionContext = MessageContextFactory.newInstance(this, validator);
                    expressionContext.putAll(params);
                    valid = false;
                    found = true;
                    message = validator.getMessage(new ValidatorContextImpl(expressionContext, this));

                    if (message == null) {
View Full Code Here

    /** 验证(或重新验证)字段。 */
    protected void validate() {
        valid = true;

        for (Validator validator : getFieldConfig().getValidators()) {
            MessageContext expressionContext = MessageContextFactory.newInstance(this, validator);
            Context context = new ValidatorContextImpl(expressionContext, this);
            boolean passed = validator.validate(context);

            if (!passed) {
                valid = false;
View Full Code Here

     * <li>所有系统属性:<code>System.getProperties()</code>。</li>
     * <li>常用小工具如:<code>stringUtil</code>和<code>stringEscapeUtil</code>等。</li>
     * </ol>
     */
    public static MessageContext newInstance(final Form form) {
        MessageContext formContext = new MessageContext() {
            @Override
            protected Object internalGet(String key) {
                return null;
            }

            @Override
            public ExpressionContext getParentContext() {
                return null;
            }

            @Override
            protected void buildToString(ToStringBuilder sb) {
                sb.append("FormMessageContext");
            }

            @Override
            protected void buildToString(MapBuilder mb) {
                mb.append("form", form);
            }
        };

        Map<String, Object> utils = Utils.getUtils();

        formContext.putAll(System.getProperties());
        formContext.putAll(utils);

        return formContext;
    }
View Full Code Here

     * <li><code>form</code>指向当前表单对象</li>
     * <li>Group中的所有field。</li>
     * </ol>
     */
    public static MessageContext newInstance(final Group group) {
        MessageContext groupContext = new MessageContext() {
            @Override
            protected Object internalGet(String key) {
                Object value = null;

                // 查找fields
View Full Code Here

     * <code>values</code>、<code>defaultValue</code>和<code>defaultValues</code>。
     * </li>
     * </ol>
     */
    public static MessageContext newInstance(final Field field) {
        MessageContext fieldContext = new MessageContext() {
            private BeanWrapper fieldWrapper;

            @Override
            protected Object internalGet(String key) {
                if (fieldWrapper == null) {
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.form.MessageContext

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.