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

MVVM viewmodel name bleed into include / other idspace

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 8.5.1.2
    • Fix Version/s: 8.5.2
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None
    • gh.sprint.customfield.default.name:
      ZK 8.5.2 S2

      Description

      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

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  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