Criado uma constraint para o usuario nao inserir o campo valor = null

fixes bug#11105 
dev:valdevir
qua:victor


git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@82053 d1611594-4594-4d17-8e1d-87c2c4800839
master
claudio 2018-05-23 18:49:40 +00:00
parent 0a1512ab62
commit fc334c61f2
2 changed files with 27 additions and 1 deletions

View File

@ -0,0 +1,26 @@
package com.rjconsultores.ventaboletos.web.utilerias;
import java.math.BigDecimal;
import org.zkoss.util.resource.Labels;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zul.Constraint;
/**
*
* @author Claudio
*/
public class ConstraintDecimalBoxNumberValid implements Constraint {
public void validate(Component comp, Object value) throws WrongValueException {
try {
new BigDecimal(value.toString().replace(".", "").replace(",", "."));
} catch (NumberFormatException e) {
throw new WrongValueException(comp,
Labels.getLabel("MSG.CONSTRAINT.DECIMALBOXISNOTANUMBER"));
} catch (NullPointerException e) {
throw new WrongValueException(comp,
Labels.getLabel("MSG.CONSTRAINT.DECIMALBOXISNOTANUMBER"));
}
}
}

View File

@ -32,7 +32,7 @@
<rows> <rows>
<row> <row>
<label value="${c:l('editarPricingController.importe.value')}"/> <label value="${c:l('editarPricingController.importe.value')}"/>
<textbox id="importe" constraint="no empty, no zero, no negative" precision="7" scale="2" <textbox id="importe" constraint="${c:new('com.rjconsultores.ventaboletos.web.utilerias.ConstraintDecimalBoxNumberValid')}" precision="7" scale="2"
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextboxDecimal" use="com.rjconsultores.ventaboletos.web.utilerias.MyTextboxDecimal"
value="@{winEditarPricingImporte$composer.pricingImporte.importe, value="@{winEditarPricingImporte$composer.pricingImporte.importe,
converter=com.rjconsultores.ventaboletos.web.utilerias.StringDecimalToDecimalConverter}"/> converter=com.rjconsultores.ventaboletos.web.utilerias.StringDecimalToDecimalConverter}"/>