本文整理汇总了Java中net.sourceforge.stripes.validation.ValidationMethod类的典型用法代码示例。如果您正苦于以下问题:Java ValidationMethod类的具体用法?Java ValidationMethod怎么用?Java ValidationMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValidationMethod类属于net.sourceforge.stripes.validation包,在下文中一共展示了ValidationMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateProductCodeIsAvalaible
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
示例2: validateUserDefaultSet
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
示例3: validateLocationDefaultSet
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
示例4: validateClosedCashIsOpen
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
示例5: validateCategoryProductListIsAvalaible
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
示例6: validateCategoryListIsAvalaible
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
示例7: validateCategoryListIsAvalaible
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
示例8: validateProductNameIsUnique
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
}
示例9: validateProductCodeIsUnique
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
}
示例10: validateProductReferenceIsUnique
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
}
示例11: validateProductIdIsAvalaible
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
示例12: validateCategoryNameIsUnique
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
}
示例13: validateCategoryCodeIsUnique
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的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()));
}
}
}
示例14: validateCategoryIdIsAvalaible
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的package包/类
@ValidationMethod(on = "form")
public void validateCategoryIdIsAvalaible(ValidationErrors errors) {
try {
pcPersist.init(getDataBaseConnection());
ProductCategory category = pcPersist.read(getCategory().getId());
if (category != null) {
setCategory(category);
} else {
errors.add("category.id", new SimpleError(
getLocalizationKey("error.CatalogNotInclude")));
}
} catch (SQLException ex) {
getContext().getValidationErrors().addGlobalError(
new SimpleError(ex.getMessage()));
}
}
示例15: validateCategoryNameIsUnique
import net.sourceforge.stripes.validation.ValidationMethod; //导入依赖的package包/类
@ValidationMethod(on = "add")
public void validateCategoryNameIsUnique(ValidationErrors errors) {
String name = getCategory().getName();
if (name != null && !name.isEmpty()) {
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()));
}
}
}