List of usage examples for org.apache.commons.validator.routines.checkdigit CheckDigitException getMessage
public String getMessage()
From source file:mobi.nordpos.catalog.action.ProductCreateActionBean.java
@ValidationMethod(priority = 1) public void validateProductBarcode(ValidationErrors errors) { String prefix = getBarcodePrefix(); if (!prefix.matches("\\d\\d\\d")) { prefix = DEFAULT_BARCODE_PREFIX; }// w ww . j a va 2s.c om try { String plu = getPLU(getProduct().getProductCategory().getCode()); String code = getShortCode(); String barcode = prefix.concat(plu).concat(code); getProduct().setCode(barcode.concat(new EAN13CheckDigit().calculate(barcode))); } catch (CheckDigitException ex) { getContext().getValidationErrors().addGlobalError(new SimpleError(ex.getMessage())); } catch (SQLException ex) { getContext().getValidationErrors().addGlobalError(new SimpleError(ex.getMessage())); } }