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

@DependsOn + EL with enum causes PropertyNotFoundException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 8.5.2
    • 8.5.0
    • Databind 2
    • Security Level: Jimmy
    • None
    • happens with both ZK CE (zkbind.jar) or ZK EE (zkmax.jar)

    • ZK 8.5.2 S1, ZK 8.5.2 S2

      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. dependson-issue.zip
          16 kB
        2. depends-on-problem-ZK-3828.zul
          0.5 kB
        3. DependsOnVM_ZK3828.java
          0.6 kB
        4. Status_ZK3828.java
          0.1 kB

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

              Created:
              Updated:
              Resolved:

                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