本文整理汇总了Java中net.sourceforge.stripes.validation.SimpleError类的典型用法代码示例。如果您正苦于以下问题:Java SimpleError类的具体用法?Java SimpleError怎么用?Java SimpleError使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SimpleError类属于net.sourceforge.stripes.validation包,在下文中一共展示了SimpleError类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convert
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的package包/类
/**
* Attempt to parse the input string to an integer and look up the {@link Component} with that
* ID using a {@link ComponentManager}.
*
* @param input The input string to be parsed as the Component ID.
* @param targetType The type of object we're supposed to be returning.
* @param errors The validation errors for this request. If the input string cannot be parsed,
* then we will add a new {@link ValidationError} to this collection and return null.
*/
public Component convert(String input, Class<? extends Component> targetType,
Collection<ValidationError> errors) {
Component component = null;
try {
int id = Integer.valueOf(input);
ComponentManager componentManager = new ComponentManager();
component = componentManager.getComponent(id);
}
catch (NumberFormatException e) {
errors.add(new SimpleError("The number {0} is not a valid Component ID", input));
}
return component;
}
示例2: convert
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的package包/类
/**
* Attempt to parse the input string to an integer and look up the {@link Bug} with that ID
* using a {@link BugManager}.
*
* @param input The input string to be parsed as the Bug ID.
* @param targetType The type of object we're supposed to be returning.
* @param errors The validation errors for this request. If the input string cannot be parsed,
* then we will add a new {@link ValidationError} to this collection and return null.
*/
public Bug convert(String input, Class<? extends Bug> targetType,
Collection<ValidationError> errors) {
Bug bug = null;
try {
int id = Integer.valueOf(input);
BugManager bugManager = new BugManager();
bug = bugManager.getBug(id);
}
catch (NumberFormatException e) {
errors.add(new SimpleError("The number {0} is not a valid Bug ID", input));
}
return bug;
}
示例3: convert
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的package包/类
/**
* Attempt to parse the input string to an integer and look up the {@link Person} with that ID
* using a {@link PersonManager}.
*
* @param input The input string to be parsed as the Person ID.
* @param targetType The type of object we're supposed to be returning.
* @param errors The validation errors for this request. If the input string cannot be parsed,
* then we will add a new {@link ValidationError} to this collection and return null.
*/
public Person convert(String input, Class<? extends Person> targetType,
Collection<ValidationError> errors) {
Person person = null;
try {
int id = Integer.valueOf(input);
PersonManager personManager = new PersonManager();
person = personManager.getPerson(id);
}
catch (NumberFormatException e) {
errors.add(new SimpleError("The number {0} is not a valid Person ID", input));
}
return person;
}
示例4: validateProductCodeIsAvalaible
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的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()));
}
}
示例5: update
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的package包/类
public Resolution update() {
Customer customer = getContext().getCustomer();
try {
customerPersist.init(getDataBaseConnection());
if (customerPersist.change(customer)) {
getContext().getMessages().add(
new SimpleMessage(getLocalizationKey("message.Customer.updated"),
customer.getName()));
}
} catch (SQLException ex) {
getContext().getValidationErrors().addGlobalError(
new SimpleError(ex.getMessage()));
return getContext().getSourcePageResolution();
}
return new ForwardResolution(WelcomeActionBean.class);
}
示例6: validateUserDefaultSet
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的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()));
}
}
示例7: validateLocationDefaultSet
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的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()));
}
}
示例8: validateClosedCashIsOpen
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的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()));
}
}
示例9: validateCategoryProductListIsAvalaible
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的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()));
}
}
示例10: validateCategoryListIsAvalaible
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的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()));
}
}
示例11: delete
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的package包/类
public Resolution delete() throws SQLException {
Place place = getPlace();
try {
sharedTicketPersist.init(getDataBaseConnection());
if (sharedTicketPersist.delete(place.getId())) {
getContext().getMessages().add(
new SimpleMessage(getLocalizationKey("message.Order.deleted"),
place.getName()));
}
} catch (SQLException ex) {
getContext().getValidationErrors().addGlobalError(
new SimpleError(ex.getMessage()));
return getContext().getSourcePageResolution();
}
return new ForwardResolution(FloorListActionBean.class);
}
示例12: accept
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的package包/类
public Resolution accept() throws UnsupportedEncodingException, NoSuchAlgorithmException {
try {
userPersist.init(getDataBaseConnection());
User user = getUser();
user.setId(UUID.randomUUID().toString());
getContext().getMessages().add(
new SimpleMessage(getLocalizationKey("message.User.registered"),
userPersist.add(user).getName())
);
} catch (SQLException ex) {
getContext().getValidationErrors().addGlobalError(
new SimpleError(ex.getMessage()));
return getContext().getSourcePageResolution();
}
return new ForwardResolution(UserAuthorizationActionBean.class);
}
示例13: validateCategoryListIsAvalaible
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的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()));
}
}
示例14: update
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的package包/类
public Resolution update() {
User user = getContext().getUser();
try {
userPersist.init(getDataBaseConnection());
if (userPersist.change(user)) {
getContext().getMessages().add(
new SimpleMessage(getLocalizationKey("message.User.updated"),
user.getName()));
}
} catch (SQLException ex) {
getContext().getValidationErrors().addGlobalError(
new SimpleError(ex.getMessage()));
return getContext().getSourcePageResolution();
}
return new ForwardResolution(WelcomeActionBean.class);
}
示例15: update
import net.sourceforge.stripes.validation.SimpleError; //导入依赖的package包/类
public Resolution update() {
Product product = getProduct();
BigDecimal taxRate = product.getTax().getRate();
BigDecimal bdTaxRateMultiply = taxRate.add(BigDecimal.ONE);
product.setPriceSell(product.getTaxPriceSell().divide(bdTaxRateMultiply, MathContext.DECIMAL64));
try {
productPersist.init(getDataBaseConnection());
if (productPersist.change(product)) {
getContext().getMessages().add(
new SimpleMessage(getLocalizationKey("message.Product.updated"),
product.getName()));
}
} catch (SQLException ex) {
getContext().getValidationErrors().addGlobalError(
new SimpleError(ex.getMessage()));
return getContext().getSourcePageResolution();
}
return new ForwardResolution(ProductViewActionBean.class);
}