BigDecimal subtotal = controlSubtotal.getBigDecimal();
BigDecimal discount = controlDiscount.getBigDecimal();
if (subtotal!=null && discount!=null) {
// no outboxing must be used, in order to ensure java 1.4 compatibilty
// moreover, the primitive division is not the best choice (do not ensure correct decimals...)
controlDiscountPerc.setValue( discount.divide(subtotal,5,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100d)) );
} else {
controlDiscountPerc.setValue(null);
}
}