AnnotateDataBinder: when the expr is pointing to a NULL object

asked 2013-04-15 15:21:46 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6

updated 2013-04-15 21:05:39 +0800

Hello Folks!

Assuming the following:

    public class ClassOne {

    private ClassTwo two;

    public ClassTwo getTwo() {
        return two;

    public void setTwo(ClassTwo two) {
        this.two = two;



    public class ClassTwo {

    private String name;

    public String getName() {
        return name;

    public void setName(String name) {
        this.name = name;



    <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

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2013-04-16 02:59:37 +0800

ashishd gravatar image ashishd flag of Taiwan
1972 6

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.

link publish delete flag offensive edit

answered 2013-04-16 07:34:02 +0800

gganassin gravatar image gganassin flag of Luxembourg
540 6

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!

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

1 follower



Asked: 2013-04-15 15:21:46 +0800

Seen: 22 times

Last updated: Apr 16 '13

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More