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

@DependsOn + EL with enum causes PropertyNotFoundException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 8.5.0
    • Fix Version/s: 8.5.2
    • Component/s: Databind 2
    • Security Level: Jimmy
    • Labels:
      None
    • Environment:

      happens with both ZK CE (zkbind.jar) or ZK EE (zkmax.jar)

    • gh.sprint.customfield.default.name:
      ZK 8.5.2 S1, ZK 8.5.2 S2

      Description

      Steps to Reproduce

      run the attached simplified example

      Current Result

      the EL @load(vm.status eq Status_ZK3828.OK) in combination with a @DependsOn("message") at getStatus causes the following Exception
      -> indicating a problem during @DependsOn tracking

      org.zkoss.zel.PropertyNotFoundException: No public static field named [message] was found on class [zk.support.bugs.Status_ZK3828]
      	at org.zkoss.zel.StaticFieldELResolver.getValue(StaticFieldELResolver.java:66)
      	at org.zkoss.zel.CompositeELResolver.getValue(CompositeELResolver.java:66)
      	at org.zkoss.zel.CompositeELResolver.getValue(CompositeELResolver.java:66)
      	at org.zkoss.xel.zel.XelELResolver.getValue(XelELResolver.java:99)
      	at org.zkoss.bind.xel.zel.BindELResolver.getValue(BindELResolver.java:121)
      	at org.zkoss.zel.impl.parser.AstValue.getValue(AstValue.java:188)
      	at org.zkoss.zel.impl.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
      	at org.zkoss.zkmax.bind.impl.ValueExpressionImplEx.getValue(ValueExpressionImplEx.java:52)
      	at org.zkoss.xel.zel.ELXelExpression.evaluate(ELXelExpression.java:41)
      	at org.zkoss.zkmax.bind.impl.BindEvaluatorXImplEx$LazyBindXelExpression.evaluate(BindEvaluatorXImplEx.java:124)
      	at org.zkoss.bind.impl.BindEvaluatorXImpl.getValue(BindEvaluatorXImpl.java:46)
      	at org.zkoss.bind.xel.zel.BindELContext.addDependsOnTracking(BindELContext.java:354)
      	at org.zkoss.bind.xel.zel.BindELContext.addDependsOnTracking(BindELContext.java:330)
      	at org.zkoss.bind.impl.LoadPropertyBindingImpl.addDependsOnTrackings(LoadPropertyBindingImpl.java:144)
      	at org.zkoss.bind.xel.zel.BindELContext.addDependsOnTrackings(BindELContext.java:301)
      	at org.zkoss.bind.xel.zel.BindELResolver.tieValue(BindELResolver.java:331)
      	at org.zkoss.zkmax.bind.impl.BindELResolverEx.tieValue(BindELResolverEx.java:143)
      ...
      

      Expected Result

      no exception

      Workaround

      use alternative EL expressions:

      		<!-- workaround 1 reversing the order: enum first works -->
      		<label value="@load(Status_ZK3828.OK eq vm.status)"/>
      		<!-- workaround 2 compare against enum string value -->
      		<label value="@load(vm.status eq 'OK')"/>
      

      replace @DependsOn with @NotifyChange

      //	workaround 3 use @NotifyChange instead of @DependsOn
      	@NotifyChange("status")
      	public void setMessage(String message) {
      		this.message = message;
      	}
      
      //	workaround 3 use @NotifyChange instead of @DependsOn
      //	@DependsOn("message")
      	public Status_ZK3828 getStatus() {
      		return getMessage().contains("error") ? Status_ZK3828.ERROR : Status_ZK3828.OK;
      	}
      
      1. depends-on-problem-ZK-3828.zul
        0.5 kB
        cor3000
      2. DependsOnVM_ZK3828.java
        0.6 kB
        cor3000
      3. Status_ZK3828.java
        0.1 kB
        cor3000

        Activity

        Hide
        cor3000 cor3000 added a comment - - edited

        added isolated mvn project with zats test reproducing the issue

        testable via:

        mvn test
        

        apply either workaround will succeed the test

        Show
        cor3000 cor3000 added a comment - - edited added isolated mvn project with zats test reproducing the issue testable via: mvn test apply either workaround will succeed the test
        Hide
        rudyhuang rudyhuang added a comment -

        Fixed since 2018/06/29

        Show
        rudyhuang rudyhuang added a comment - Fixed since 2018/06/29

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 1 day, 4 hours
              1d 4h
              Remaining:
              Time Spent - 1 day Remaining Estimate - 4 hours
              4h
              Logged:
              Time Spent - 1 day Remaining Estimate - 4 hours
              1d

                Agile