0

Property not found on type

asked 2013-07-08 13:01:39 +0800

miks gravatar image miks
0

Hi,

I have general problem when entity is bound to a detail view.

Let say that I have Partner entity (Loaded with Spring Data JPA) and it's bound in following way to some detail view.

public class City {
    private name;
    // ... get/set
}

public class Partner {
    private String name;
    private String address;
    private City city;
    // .. get/set
}

public class PartnerViewModel {

    private Partner item;

    // get/set ...
}

<grid>
<rows>
<row>
    <label value="Name:"/>
    <textbox value="@bind(vm.item.name)" />
</row>
<row>
    <label value="Address:"/>
    <textbox value="@bind(vm.item.address)" />
</row>
<rows>
    <label value="City:"/>
    <combobox model="@load(vm.cities)" selectedItem="@bind(vm.item.city)" />
</row>
</ros>
</grid>

When the value of name textbox is changed, and focus is sent to some other control, OnChange event is fired and a org.zkoss.zel.PropertyNotFoundException is thrown. For example "Property 'name' not found on type 'City'"

After few debuging sessions I have found that problem might be in the following code in fajl BindELResolver.java.

    //save value into equal beans
private void saveEqualBeans(ELContext elCtx, Object base, String prop, Object value) {
    final BindELContext ctx = (BindELContext)((EvaluationContext)elCtx).getELContext();
    final BindContext bctx = (BindContext) ctx.getAttribute(BinderImpl.BINDCTX);

    if (bctx.getAttribute(BinderImpl.SAVE_BASE) != null) { //recursive back, return
        return; 
    }
    ctx.setAttribute(BinderImpl.SAVE_BASE, Boolean.TRUE);
    try {
        final Binder binder = bctx.getBinder();
        final TrackerImpl tracker = (TrackerImpl) ((BinderCtrl)binder).getTracker();
        final Set<Object> beans = tracker.getEqualBeans(base);
        beans.remove(base); // POSSIBLE PROBLEM
        for (Object candidate : beans) {
            super.setValue(elCtx, candidate, prop, value); //might recursive back
        }
    } finally {
        ctx.setAttribute(BinderImpl.SAVE_BASE, null);
    }
}

When method is entered, "base" is "Partner", "prop" is "name", but "base" is removed from "beans" candidates set, so it will never be found.

Posible solution is to make ViewModel adapter methods:

public String getName() {
    return this.item.getName();
}

public void setName(String name) {
    this.item.setName(name);
}

And to bind to the vm.name instead of vm.item.name, but it's time consuming.

I there any other solutions?

A have also found this code in BindEvaluatorXImpl.java

public void setValue(BindContext ctx, Component comp, ExpressionX expression, Object value)
throws XelException {
    //ZK-1063 No exception if binding to a non-existed property
    //Dennis, Removed the try-catch PropertyNotFoundException, we don't have history to check why we did try-catch before
    //However, it should throw the property-not-found to let user be aware it. 
    expression.setValue(newXelContext(ctx, comp), value);
}

Maybe because of this problem that I have stated there was PropertyNotFoundException try-catch.

delete flag offensive retag edit

Comments

It sounds like a bug, could you post to tracker http://tracker.zkoss.org/secure/Dashboard.jspa and provide the reproducible case(and code), thanks.

dennis ( 2013-07-09 02:03:02 +0800 )edit

Unfortunately I can't submit my project code, when I try to reproduce this problem with some simple example everything is working just fine. I suppose, that problem might be somewhere in my code.

miks ( 2013-07-09 10:49:45 +0800 )edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2017-11-28 12:25:46 +0800

materialgood gravatar image materialgood
1

I have the same problem, someone knows what is happening, copy all the code of another project that works if it works and it still does not work.

link publish delete flag offensive edit

Comments

zk version? can you reproduce the issue in ZK fiddle?

chillworld ( 2017-11-28 16:07:11 +0800 )edit
0

answered 2017-11-28 12:25:13 +0800

materialgood gravatar image materialgood
1

tengo el mismo problema, alguien sabe qe es lo qe pasa?, copie todo el codigo de otro proyecto qe si funciona en este y aun no funciona.

link publish delete flag offensive edit
0

answered 2013-11-13 13:44:53 +0800

gtrindade gravatar image gtrindade
1

Hi. I'm getting the same error. Were any of you able to solve this ?

Thanks

G

link publish delete flag offensive edit
0

answered 2013-08-25 09:10:45 +0800

alexprawira gravatar image alexprawira
15

I'm facing the same problem here. Strangely it doesnt reproduce with other codes. My other codes works fine, except for this one. I tried, but i cant find out why its happening only in this particular code.

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

Follow
1 follower

RSS

Stats

Asked: 2013-07-08 13:01:39 +0800

Seen: 111 times

Last updated: Nov 28 '17

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