Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-3970

MVVM viewmodel name bleed into include / other idspace

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major Major
    • 8.5.2
    • None
    • None
    • Security Level: Jimmy
    • None

      Steps to Reproduce

      run fiddle
      http://zkfiddle.org/sample/br92rk/3-view-model-same-name-bleeding-in-include

      There are 2 pages:
      index (using outerVm)
      include (using innerVm)

      in the include page, the innerVm is declared with the name (vm) and has a getStringValue method which can be resolved to vm.stringValue in databinding

      <label value="@load(vm.stringValue)" />
      

      on ZK 8.5.1 and later, If the parent page hold a different VM object with the same name (vm), the binding will be resolved on the outerVM object instead of the direct parent VM of the binding

      This trigger an exception such as:

      org.zkoss.zel.PropertyNotFoundException: Property 'stringValue' not found on type OuterVm
      	at org.zkoss.zel.BeanELResolver$BeanProperties.get(BeanELResolver.java:426)
      	at org.zkoss.zel.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:376)
      	at org.zkoss.zel.BeanELResolver.property(BeanELResolver.java:549)
      

      Expected Result

      The binding should be resolved on the closest parent vm, located in the same idspace / page

      Debug Info

      see comments

      Root Cause

      Workaround

      change name of one of the vms to avoid same name in multiple VM bindings

            rudyhuang rudyhuang
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: