当前位置: 首页>>代码示例>>Java>>正文


Java ModelDriven类代码示例

本文整理汇总了Java中com.opensymphony.xwork2.ModelDriven的典型用法代码示例。如果您正苦于以下问题:Java ModelDriven类的具体用法?Java ModelDriven怎么用?Java ModelDriven使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ModelDriven类属于com.opensymphony.xwork2包,在下文中一共展示了ModelDriven类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: intercept

import com.opensymphony.xwork2.ModelDriven; //导入依赖的package包/类
@Override
public String intercept(ActionInvocation invocation) throws Exception {
    Object action = invocation.getAction();

    if (action instanceof ModelDriven) {
        ModelDriven modelDriven = (ModelDriven) action;
        ValueStack stack = invocation.getStack();
        Object model = modelDriven.getModel();
        if (model !=  null) {
        	stack.push(model);
        }
        if (refreshModelBeforeResult) {
            invocation.addPreResultListener(new RefreshModelBeforeResult(modelDriven, model));
        }
    }
    return invocation.invoke();
}
 
开发者ID:txazo,项目名称:struts2,代码行数:18,代码来源:ModelDrivenInterceptor.java

示例2: performBeanValidation

import com.opensymphony.xwork2.ModelDriven; //导入依赖的package包/类
@SuppressWarnings("nls")
protected void performBeanValidation(Object action, Validator validator) {

    LOG.debug("Initiating bean validation..");

    Set<ConstraintViolation<Object>> constraintViolations;

    if (action instanceof ModelDriven) {
        LOG.debug("Performing validation on model..");
        constraintViolations = validator.validate(((ModelDriven) action).getModel());
    } else {
        LOG.debug("Performing validation on action..");
        constraintViolations = validator.validate(action);
    }

    addBeanValidationErrors(constraintViolations, action);
}
 
开发者ID:umeshawasthi,项目名称:jsr303-validator-plugin,代码行数:18,代码来源:JSR303ValidationInterceptor.java

示例3: addBeanValidationErrors

import com.opensymphony.xwork2.ModelDriven; //导入依赖的package包/类
@SuppressWarnings("nls")
private void addBeanValidationErrors(Set<ConstraintViolation<Object>> constraintViolations, Object action) {
    if (constraintViolations != null) {
        ValidatorContext validatorContext = new DelegatingValidatorContext(action);
        for (ConstraintViolation<Object> constraintViolation : constraintViolations) {
            String key = constraintViolation.getMessage();
            String message = key;
            try {
                message = validatorContext.getText(key);
                if(convertToUtf8 && StringUtils.isNotBlank(message)) {
                    message = new String(message.getBytes(convertFromEncoding), "UTF-8");
                }
            } catch (Exception e) {
                LOG.error("Error while trying to fetch message", e);
            }

            if (isActionError(constraintViolation)) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Adding action error '#0'", message);
                }
                validatorContext.addActionError(message);
            } else {

                ValidationError validationError = buildBeanValidationError(constraintViolation, message);
                String fieldName = validationError.getFieldName();
                if (action instanceof ModelDriven && fieldName.startsWith(ValidatorConstants.MODELDRIVEN_PREFIX)) {
                    fieldName = fieldName.replace("model.", ValidatorConstants.EMPTY_SPACE);
                }
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Adding field error [#0] with message '#1'", fieldName, validationError.getMessage());
                }
                validatorContext.addFieldError(fieldName, validationError.getMessage());
            }
        }
     }
}
 
开发者ID:umeshawasthi,项目名称:jsr303-validator-plugin,代码行数:37,代码来源:JSR303ValidationInterceptor.java

示例4: RefreshModelBeforeResult

import com.opensymphony.xwork2.ModelDriven; //导入依赖的package包/类
public RefreshModelBeforeResult(ModelDriven action, Object model) {
    this.originalModel = model;
    this.action = action;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:5,代码来源:ModelDrivenInterceptor.java


注:本文中的com.opensymphony.xwork2.ModelDriven类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。