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

MVVM viewmodel name bleed into include / other idspace

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 8.5.2
    • 8.5.1.2
    • None
    • Security Level: Jimmy
    • None
    • ZK 8.5.2 S2

      Steps to Reproduce

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

      Current Result

      Page fails to render due to exception when processing databinding for the expression

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

      Exception:

      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)
      

      If 2 viewmodels are declared with the same variable. One of them is declared on a child of the component holding the original vm.
      A binding for a method located inside the inner vm will be processed as if the variable was referring to the outer vm. (in this case, the getStringValue() method is located on the inner VM but the EL is resolved on the outerVM object).

      (not sure if affected by <include> but couldn't reproduce after removing the include and consolidating in the same page)

      Expected Result

      before 8.5.1, this expression would correctly resolve on the innerVm getStringValue method

      Debug Info

      Start to happen after commit linked in comments

      Root Cause

      Workaround

      Use a different name variable for the outer and inner vms

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

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Time Spent - 3 hours Remaining Estimate - 5 hours
                5h
                Logged:
                Time Spent - 3 hours Remaining Estimate - 5 hours
                3h