From 7c6a43baf63cf987d650e8fb6c4fa33e42075ed6 Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Mon, 27 Oct 2014 13:24:53 +0100 Subject: [PATCH] =?UTF-8?q?Nastaven=C3=AD=20hodnot=20middle=20objektu=20be?= =?UTF-8?q?z=20validace.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #169 --- .../info/bukova/isspst/ui/BindingForm.java | 30 +++++++++++++++---- .../ui/main/orders/created/OrderForm.java | 2 ++ .../webapp/main/orders/created/orderForm.zul | 2 +- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/main/java/info/bukova/isspst/ui/BindingForm.java b/src/main/java/info/bukova/isspst/ui/BindingForm.java index b380fd5b..2c84623b 100644 --- a/src/main/java/info/bukova/isspst/ui/BindingForm.java +++ b/src/main/java/info/bukova/isspst/ui/BindingForm.java @@ -2,7 +2,7 @@ package info.bukova.isspst.ui; import java.lang.reflect.InvocationTargetException; -import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.beanutils.PropertyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.zkoss.bind.SimpleForm; @@ -34,12 +34,32 @@ public class BindingForm extends SimpleForm { */ public void bindTo(T object) { for (String key : getFieldNames()) { - try { - BeanUtils.setProperty(object, key, getField(key)); - } catch (IllegalAccessException e) { + // try { + // BeanUtils.setProperty(object, key, getField(key)); + // + // } catch (IllegalAccessException e) { + // logger.warn("Cannot bind value", e); + // } catch (InvocationTargetException e) { + // logger.warn("Cannot bind value", e); + // } + try + { + PropertyUtils.setProperty(object, key, getField(key)); + } + catch (NoSuchMethodException e) + { + logger.warn("Cannot bind value " + key + " (" + e.getMessage() + ")"); + // e.printStackTrace(); + } + catch (IllegalAccessException e) + { logger.warn("Cannot bind value", e); - } catch (InvocationTargetException e) { + e.printStackTrace(); + } + catch (InvocationTargetException e) + { logger.warn("Cannot bind value", e); + e.printStackTrace(); } } } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderForm.java b/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderForm.java index 4d013a57..b374199a 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderForm.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderForm.java @@ -194,6 +194,7 @@ public class OrderForm extends FormViewModel @NotifyChange("dataBean") public void doFillSuppAddress() { + this.getDataForm().bind(); AddressEmb addr; if (this.selectedSuppAddrItem == null) @@ -215,6 +216,7 @@ public class OrderForm extends FormViewModel @NotifyChange("dataBean") public void doFillDeliveryAddress() { + this.getDataForm().bind(); AddressEmb addr; if (this.selectedDeliveryAddrItem == null) diff --git a/src/main/webapp/main/orders/created/orderForm.zul b/src/main/webapp/main/orders/created/orderForm.zul index e8c1c874..f11d9b9d 100644 --- a/src/main/webapp/main/orders/created/orderForm.zul +++ b/src/main/webapp/main/orders/created/orderForm.zul @@ -18,7 +18,7 @@ label="${labels.Order}" />