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


Java ValidationErrors类代码示例

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


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

示例1: hasErrors

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
/** Indicates if validation errors exist for the given field of the given {@link ActionBean}. */
public static boolean hasErrors(ActionBean actionBean, String field) {
    if (actionBean == null || field == null)
        return false;

    ActionBeanContext context = actionBean.getContext();
    if (context == null)
        return false;

    ValidationErrors errors = context.getValidationErrors();
    if (errors == null || errors.isEmpty())
        return false;

    List<ValidationError> fieldErrors = errors.get(field);
    return fieldErrors != null && fieldErrors.size() > 0;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:ElFunctions.java

示例2: logValidationErrors

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
/** Log validation errors at DEBUG to help during development. */
public static final void logValidationErrors(ActionBeanContext context) {
    StringBuilder buf = new StringBuilder("The following validation errors need to be fixed:");

    for (List<ValidationError> list : context.getValidationErrors().values()) {
        for (ValidationError error : list) {
            String fieldName = error.getFieldName();
            if (ValidationErrors.GLOBAL_ERROR.equals(fieldName))
                fieldName = "GLOBAL";

            String message;
            try {
                message = error.getMessage(Locale.getDefault());
            }
            catch (MissingResourceException e) {
                message = "(missing resource)";
            }

            buf.append("\n    -> [").append(fieldName).append("] ").append(message);
        }
    }

    log.debug(buf);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:25,代码来源:DispatcherHelper.java

示例3: validateProductCodeIsAvalaible

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod
public void validateProductCodeIsAvalaible(ValidationErrors errors) {
    TaxPersist taxPersist = new TaxPersist();
    try {
        productPersist.init(getDataBaseConnection());
        taxPersist.init(getDataBaseConnection());
        Product product = productPersist.find(Product.CODE, getProduct().getCode());
        if (product != null) {
            product.setTax(taxPersist.read(product.getTaxCategory().getId()));
            setProduct(product);
        } else {
            errors.add("product.code", new SimpleError(
                    getLocalizationKey("error.CatalogNotInclude")));
        }
    } catch (SQLException ex) {
        getContext().getValidationErrors().addGlobalError(
                new SimpleError(ex.getMessage()));
    }
}
 
开发者ID:nordpos-mobi,项目名称:online-retail,代码行数:20,代码来源:OrderProductActionBean.java

示例4: validateUserDefaultSet

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod
public void validateUserDefaultSet(ValidationErrors errors) {
    try {
        userPersist.init(getDataBaseConnection());
        String userId = getContext().getServletContext().getInitParameter(POS_USER_ID);
        if (userId == null || userId.isEmpty()) {
            userId = DEFAULT_USER_ID;
        }
        user = userPersist.read(userId);
        if (user == null) {
            errors.add("user.id", new SimpleError(
                    getLocalizationKey("error.DefaultUserNotRegistration"), userId));
        }
    } catch (SQLException ex) {
        getContext().getValidationErrors().addGlobalError(
                new SimpleError(ex.getMessage()));
    }
}
 
开发者ID:nordpos-mobi,项目名称:online-retail,代码行数:19,代码来源:BaseActionBean.java

示例5: validateLocationDefaultSet

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod
public void validateLocationDefaultSet(ValidationErrors errors) {
    try {
        locationPersist.init(getDataBaseConnection());
        String locationId = getContext().getServletContext().getInitParameter(POS_LOCATION_ID);
        if (locationId == null || locationId.isEmpty()) {
            locationId = DEFAULT_LOCATION_ID;
        }
        location = locationPersist.read(locationId);
        if (location == null) {
            errors.add("location.id", new SimpleError(
                    getLocalizationKey("error.DefaultLocationNotRegistration"), locationId));
        }
    } catch (SQLException ex) {
        getContext().getValidationErrors().addGlobalError(
                new SimpleError(ex.getMessage()));
    }
}
 
开发者ID:nordpos-mobi,项目名称:online-retail,代码行数:19,代码来源:BaseActionBean.java

示例6: validateClosedCashIsOpen

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod(on = "accept")
public void validateClosedCashIsOpen(ValidationErrors errors) throws UnknownHostException {
    String hostName = getHostName();
    ClosedCashPersist closedCashPersist = new ClosedCashPersist();
    try {
        closedCashPersist.init(getDataBaseConnection());
        openCash = closedCashPersist.readOpen(hostName);
        if (openCash == null) {
            openCash = new ClosedCash();
            openCash.setHost(hostName);
            openCash.setHostSequence(1);
            openCash.setDateStart(new Date());
            openCash = closedCashPersist.add(openCash);
        }
    } catch (SQLException ex) {
        getContext().getValidationErrors().addGlobalError(
                new SimpleError(ex.getMessage()));
    }

}
 
开发者ID:nordpos-mobi,项目名称:online-retail,代码行数:21,代码来源:OrderPostActionBean.java

示例7: validateCategoryProductListIsAvalaible

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod
public void validateCategoryProductListIsAvalaible(ValidationErrors errors) {
    try {
        pcPersist.init(getDataBaseConnection());
        TaxPersist taxPersist = new TaxPersist();
        taxPersist.init(getDataBaseConnection());
        ProductCategory category = pcPersist.read(getCategory().getId());
        if (category != null) {
            setCategory(category);
            List<Product> products = pcPersist.readProductList(category);
            for (int j = 0; j < products.size(); j++) {
                Product product = products.get(j);
                product.setTax(taxPersist.read(product.getTaxCategory().getId()));
                products.set(j, product);
            }
            setProductList(products);
        } else {
            errors.add("category.id", new SimpleError(
                    getLocalizationKey("error.CatalogNotInclude")));
        }
    } catch (SQLException ex) {
        getContext().getValidationErrors().addGlobalError(
                new SimpleError(ex.getMessage()));
    }
}
 
开发者ID:nordpos-mobi,项目名称:online-retail,代码行数:26,代码来源:CategoryProductListActionBean.java

示例8: validateCategoryListIsAvalaible

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod
public void validateCategoryListIsAvalaible(ValidationErrors errors) {
    try {
        pcPersist.init(getDataBaseConnection());
        List<ProductCategory> categories = pcPersist.readList();
        for (int i = 0; i < categories.size(); i++) {
            ProductCategory category = categories.get(i);
            List<Product> products = pcPersist.readProductList(category);
            category.setProductList(products);
            categories.set(i, category);
        }
        setCategoryList(categories);
    } catch (SQLException ex) {
        getContext().getValidationErrors().addGlobalError(
                new SimpleError(ex.getMessage()));
    }
}
 
开发者ID:nordpos-mobi,项目名称:online-retail,代码行数:18,代码来源:CategoryListActionBean.java

示例9: validateCategoryListIsAvalaible

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod
public void validateCategoryListIsAvalaible(ValidationErrors errors) {
    ProductCategoryPersist pcPersist = new ProductCategoryPersist();
    TaxPersist taxPersist = new TaxPersist();
    try {
        pcPersist.init(getDataBaseConnection());
        taxPersist.init(getDataBaseConnection());
        List<ProductCategory> categories = pcPersist.readList();
        for (int i = 0; i < categories.size(); i++) {
            ProductCategory category = categories.get(i);
            List<Product> products = pcPersist.readProductList(category);
            for (int j = 0; j < products.size(); j++) {
                Product product = products.get(j);
                product.setTax(taxPersist.read(product.getTaxCategory().getId()));
                products.set(j, product);
            }
            category.setProductList(products);
            categories.set(i, category);
        }
        setCategoryList(categories);
    } catch (SQLException ex) {
        getContext().getValidationErrors().addGlobalError(
                new SimpleError(ex.getMessage()));
    }
}
 
开发者ID:nordpos-mobi,项目名称:restaurant-service,代码行数:26,代码来源:CategoryProductListActionBean.java

示例10: validateProductNameIsUnique

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod(on = "update")
public void validateProductNameIsUnique(ValidationErrors errors) {
    String name = getProduct().getName();
    if (name != null && !name.isEmpty() && !name.equals(getCurrentProduct().getName())) {
        try {
            productPersist.init(getDataBaseConnection());
            if (productPersist.find(Product.NAME, name) != null) {
                errors.add("product.name", new SimpleError(
                        getLocalizationKey("error.Product.AlreadyExists"), name));
            }
        } catch (SQLException ex) {
            getContext().getValidationErrors().addGlobalError(
                    new SimpleError(ex.getMessage()));
        }
    }
}
 
开发者ID:nordpos-mobi,项目名称:product-catalog,代码行数:17,代码来源:ProductChangeActionBean.java

示例11: validateProductCodeIsUnique

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod(on = "update")
public void validateProductCodeIsUnique(ValidationErrors errors) {
    String code = getProduct().getCode();
    if (code != null && !code.isEmpty() && !code.equals(getCurrentProduct().getCode())) {
        try {
            productPersist.init(getDataBaseConnection());
            if (productPersist.find(Product.CODE, code) != null) {
                errors.add("product.code", new SimpleError(
                        getLocalizationKey("error.Product.AlreadyExists"), code));
            }
        } catch (SQLException ex) {
            getContext().getValidationErrors().addGlobalError(
                    new SimpleError(ex.getMessage()));
        }
    }
}
 
开发者ID:nordpos-mobi,项目名称:product-catalog,代码行数:17,代码来源:ProductChangeActionBean.java

示例12: validateProductReferenceIsUnique

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod(on = "update")
public void validateProductReferenceIsUnique(ValidationErrors errors) {
    String reference = getProduct().getReference();
    if (reference != null && !reference.isEmpty() && !reference.equals(getCurrentProduct().getReference())) {
        try {
            productPersist.init(getDataBaseConnection());
            if (productPersist.find(Product.REFERENCE, reference) != null) {
                errors.add("product.reference", new SimpleError(
                        getLocalizationKey("error.Product.AlreadyExists"), reference));
            }
        } catch (SQLException ex) {
            getContext().getValidationErrors().addGlobalError(
                    new SimpleError(ex.getMessage()));
        }
    }
}
 
开发者ID:nordpos-mobi,项目名称:product-catalog,代码行数:17,代码来源:ProductChangeActionBean.java

示例13: validateProductIdIsAvalaible

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod(on = "form")
public void validateProductIdIsAvalaible(ValidationErrors errors) {
    try {
        productPersist.init(getDataBaseConnection());
        taxPersist.init(getDataBaseConnection());
        Product product = productPersist.read(getProduct().getId());
        if (product != null) {
            product.setTax(taxPersist.read(product.getTaxCategory().getId()));
            setProduct(product);
        } else {
            errors.add("product.id", new SimpleError(
                    getLocalizationKey("error.CatalogNotInclude")));
        }
    } catch (SQLException ex) {
        getContext().getValidationErrors().addGlobalError(
                new SimpleError(ex.getMessage()));
    }
}
 
开发者ID:nordpos-mobi,项目名称:product-catalog,代码行数:19,代码来源:ProductChangeActionBean.java

示例14: validateCategoryNameIsUnique

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod(on = "update")
public void validateCategoryNameIsUnique(ValidationErrors errors) {
    String name = getCategory().getName();
    if (name != null && !name.isEmpty() && !name.equals(currentCategory.getName())) {
        try {
            pcPersist.init(getDataBaseConnection());
            if (pcPersist.find(ProductCategory.NAME, name) != null) {
                errors.add("category.name", new SimpleError(
                        getLocalizationKey("error.ProductCategory.AlreadyExists"), name));
            }
        } catch (SQLException ex) {
            getContext().getValidationErrors().addGlobalError(
                    new SimpleError(ex.getMessage()));
        }
    }
}
 
开发者ID:nordpos-mobi,项目名称:product-catalog,代码行数:17,代码来源:CategoryChangeActionBean.java

示例15: validateCategoryCodeIsUnique

import net.sourceforge.stripes.validation.ValidationErrors; //导入依赖的package包/类
@ValidationMethod(on = "update")
public void validateCategoryCodeIsUnique(ValidationErrors errors) {
    String code = getCategory().getCode();
    if (code != null && !code.isEmpty() && !code.equals(currentCategory.getCode())) {
        try {
            pcPersist.init(getDataBaseConnection());
            if (pcPersist.find(ProductCategory.CODE, code) != null) {
                errors.add("category.code", new SimpleError(
                        getLocalizationKey("error.ProductCategory.AlreadyExists"), code));
            }
        } catch (SQLException ex) {
            getContext().getValidationErrors().addGlobalError(
                    new SimpleError(ex.getMessage()));
        }
    }
}
 
开发者ID:nordpos-mobi,项目名称:product-catalog,代码行数:17,代码来源:CategoryChangeActionBean.java


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