Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JFace数据绑定多功能扫描仪未重新评估_Java_Validation_Data Binding_Jface_Eclipse Databinding - Fatal编程技术网

Java JFace数据绑定多功能扫描仪未重新评估

Java JFace数据绑定多功能扫描仪未重新评估,java,validation,data-binding,jface,eclipse-databinding,Java,Validation,Data Binding,Jface,Eclipse Databinding,我已经设置了一个Multiclidator,以检查两个文本字段的总和是否等于另一个字段的值。然而,由于某些原因,验证器在初始化时只验证一次。在初始化时,它总是成功的。失败条件仅在向导中的稍后点触发(条件在向导的第1页失败,验证程序在第3页失败) 以下是数据绑定本身以及Multilidator的代码。dbFactory是一个方便的类,用于设置绑定本身,该部分工作正常 fixedFeeAmountBinding = dbFactory.addBinding(fixedFeeAmountTxt, "f

我已经设置了一个
Multiclidator
,以检查两个文本字段的总和是否等于另一个字段的值。然而,由于某些原因,验证器在初始化时只验证一次。在初始化时,它总是成功的。失败条件仅在向导中的稍后点触发(条件在向导的第1页失败,验证程序在第3页失败)

以下是数据绑定本身以及
Multilidator
的代码。
dbFactory
是一个方便的类,用于设置绑定本身,该部分工作正常

fixedFeeAmountBinding = dbFactory.addBinding(fixedFeeAmountTxt, "fixedAmount", null,
        new UpdateValueStrategy().setConverter(NumberToStringConverter
                .fromBigDecimal(new com.ibm.icu.text.DecimalFormat(Formats.AMOUNT_FORMAT))));
variableFeeAmountBinding = dbFactory.addBinding(variableFeeAmountTxt, "variableAmount", null,
        new UpdateValueStrategy().setConverter(NumberToStringConverter
                .fromBigDecimal(new com.ibm.icu.text.DecimalFormat(Formats.AMOUNT_FORMAT))));

MultiValidator feeAmountValidaotr = new MultiValidator() {

    @Override
    protected IStatus validate() {
        if (model.getVal().getClientChequePaymentRecordType().equals(ClientChequePaymentRecordType.INVOICE)
                && model.getVal().getInvoiceType() != null
                && !model.getVal().getInvoiceType().equals(InvoiceType.OTHER)) {
            BigDecimal fixedAmountValue = new BigDecimal(
                    String.valueOf(((IObservableValue) fixedFeeAmountBinding.getTarget()).getValue())
                            .replaceAll(",", ""));
            BigDecimal variableAmountValue = new BigDecimal(
                    String.valueOf(((IObservableValue) variableFeeAmountBinding.getTarget()).getValue())
                            .replaceAll(",", ""));
            if (fixedAmountValue.add(variableAmountValue).compareTo(model.getVal().getInvoiceAmount()) == 0) {
                return ValidationStatus.OK_STATUS;
            }
            return ValidationStatus.error("Fee Amounts don't add up to Invoice Amount");
        }
        return ValidationStatus.OK_STATUS; // <-- Doesn't update after returning this
    }
};

dbFactory.addValidationStatusProvider(feeAmountValidaotr);
fixedFeeAmountBinding=dbFactory.addBinding(fixedFeeAmountTxt,“fixedAmount”,null,
新的UpdateValueStrategy().setConverter(NumberToStringConverter
.fromBigDecimal(新的com.ibm.icu.text.DecimalFormat(Formats.AMOUNT\u FORMAT));
variableFeeAmountBinding=dbFactory.addBinding(variableFeeAmountTxt,“variableAmount”,null,
新的UpdateValueStrategy().setConverter(NumberToStringConverter
.fromBigDecimal(新的com.ibm.icu.text.DecimalFormat(Formats.AMOUNT\u FORMAT));
Multipolidator feeAmountValidaotr=新的Multipolidator(){
@凌驾
受保护的IStatus验证(){
如果(model.getVal().getClientChequePaymentRecordType().equals)(ClientChequePaymentRecordType.INVOICE)
&&model.getVal().getInvoiceType()!=null
&&!model.getVal().getInvoiceType().equals(InvoiceType.OTHER)){
BigDecimal fixedAmountValue=新的BigDecimal(
String.valueOf(((IObservableValue)fixedFeeAmountBinding.getTarget()).getValue())
.replaceAll(“,”,“);
BigDecimal variableMountValue=新的BigDecimal(
String.valueOf(((IObservableValue)variableFeeAmountBinding.getTarget()).getValue())
.replaceAll(“,”,“);
if(fixedAmountValue.add(variableAmountValue.compareTo)(model.getVal().getInvoiceAmount())==0){
返回ValidationStatus.OK_状态;
}
返回ValidationStatus.error(“费用金额加起来与发票金额不符”);
}

return ValidationStatus.OK_STATUS;//似乎我找到了问题的解决方案……我用金额字段的绑定值替换了
model.getVal().getInvoiceAmount()
调用,然后将
大小数的创建移动到
IF
之前。整个代码现在看起来如下:

MultiValidator feeAmountValidaotr = new MultiValidator() {

    @Override
    protected IStatus validate() {
        // Only validate Fee Amounts if cheque can have fees
        BigDecimal fixedAmountValue = new BigDecimal(
                String.valueOf(((IObservableValue) fixedFeeAmountBinding.getTarget()).getValue())
                        .replaceAll(",", ""));
        BigDecimal variableAmountValue = new BigDecimal(
                String.valueOf(((IObservableValue) variableFeeAmountBinding.getTarget()).getValue())
                        .replaceAll(",", ""));
        BigDecimal totalAmountValue = new BigDecimal(
                String.valueOf(((IObservableValue) amountBinding.getTarget()).getValue()).replaceAll(",", ""));
        if (getModelObject().getClientChequePaymentRecordType().equals(ClientChequePaymentRecordType.INVOICE)
                && getModelObject().getInvoiceType() != null
                && !getModelObject().getInvoiceType().equals(InvoiceType.OTHER)) {
            if (fixedAmountValue.add(variableAmountValue).compareTo(totalAmountValue) == 0) {
                return ValidationStatus.OK_STATUS;
            }
            return ValidationStatus.error("Fee Amounts don't add up to Invoice Amount");
        }
        return ValidationStatus.OK_STATUS;
    }
};

dbf.addValidationStatusProvider(feeAmountValidaotr);

似乎我找到了问题的解决方案…我用amount字段的绑定值替换了
model.getVal().getInvoiceAmount()
调用,然后将
大小数的创建移动到
IF
之前。整个代码现在如下所示:

MultiValidator feeAmountValidaotr = new MultiValidator() {

    @Override
    protected IStatus validate() {
        // Only validate Fee Amounts if cheque can have fees
        BigDecimal fixedAmountValue = new BigDecimal(
                String.valueOf(((IObservableValue) fixedFeeAmountBinding.getTarget()).getValue())
                        .replaceAll(",", ""));
        BigDecimal variableAmountValue = new BigDecimal(
                String.valueOf(((IObservableValue) variableFeeAmountBinding.getTarget()).getValue())
                        .replaceAll(",", ""));
        BigDecimal totalAmountValue = new BigDecimal(
                String.valueOf(((IObservableValue) amountBinding.getTarget()).getValue()).replaceAll(",", ""));
        if (getModelObject().getClientChequePaymentRecordType().equals(ClientChequePaymentRecordType.INVOICE)
                && getModelObject().getInvoiceType() != null
                && !getModelObject().getInvoiceType().equals(InvoiceType.OTHER)) {
            if (fixedAmountValue.add(variableAmountValue).compareTo(totalAmountValue) == 0) {
                return ValidationStatus.OK_STATUS;
            }
            return ValidationStatus.error("Fee Amounts don't add up to Invoice Amount");
        }
        return ValidationStatus.OK_STATUS;
    }
};

dbf.addValidationStatusProvider(feeAmountValidaotr);