-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello Folks!
Assuming the following:
public class ClassOne {
private ClassTwo two;
public ClassTwo getTwo() {
return two;
}
public void setTwo(ClassTwo two) {
this.two = two;
}
}
and
public class ClassTwo {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
and
<textbox value="@bind(one.two.name)" />
So: if ClassOne instance has an empty ClassTwo property ---> the databinder will try to bind it but, finding a null, it will fail to set the value in the poor name property of ClassTwo.
My problem - let's say more like a drama at the moment - is that this happens silently - without no warning or way to catch this programmatically.
Does any of you have any suggestions about HOW to solve/workaround this in order NOT to lose any change committed by the user?
Thanks! Giovanni
As you might already know this is as per EL specification (refer here for more details). If the EL variable or the property is null then the expression is ignored. I think you should not work around this. Instead make sure your EL is/will be valid before being used.
Thanks A. for your reply... however my problem is that the expressions are correct but some fields are optional in our scenario.
Some ZK versions ago (quite a few probably... when you get old time runs faster)... in the same condition i'm quite sure that the binder was throwing a NPE... now instead is silent: is there any way to listen to a failed save event in order to sort this out?
My first attempt was to deep fully initialize via introspection the beans which are composed by 130+ fields but then i have the way back problem to purge the fields that the user does not want to fulfill and this is driving me crazy due to the business logic constraints... My last stand is to try to patch the DataBinder in order to at least throw an exception when a path a.b.c can't be resolved due to a NPE.... but i'm quite reluctant to apply such an invasive refactor. Thanks in advance!
Asked: 2013-04-15 15:21:46 +0800
Seen: 22 times
Last updated: Apr 16 '13