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

Specifying a non-existing variable in "unless" attribute causes a NullPointerException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 8.0.1
    • 8.0.0
    • None
    • Security Level: Jimmy
    • None
    • ZK 8.0.1

      Steps to reproduce

      1. run a zul with the code below:
        label unless="${notExistingVar}" value="Label Text"/>
        

      actual result

      java.lang.NullPointerException
      at org.zkoss.zk.ui.util.ConditionImpl.isEffective(ConditionImpl.java:92)
      at org.zkoss.zk.ui.metainfo.BranchInfo.isEffective(BranchInfo.java:104)
      at org.zkoss.zk.ui.metainfo.ComponentInfo.isEffective(ComponentInfo.java:60)
      at org.zkoss.zk.ui.impl.UiEngineImpl.isEffective(UiEngineImpl.java:1087)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:747)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreateChild(UiEngineImpl.java:822)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate0(UiEngineImpl.java:771)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execCreate(UiEngineImpl.java:709)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage0(UiEngineImpl.java:452)
      at org.zkoss.zk.ui.impl.UiEngineImpl.execNewPage(UiEngineImpl.java:358)
      at org.zkoss.zk.ui.http.DHtmlLayoutServlet.process(DHtmlLayoutServlet.java:217)
      at org.zkoss.zk.ui.http.DHtmlLayoutServlet.doGet(DHtmlLayoutServlet.java:136)

      Debug information

      • This issue doesn't happen in ZK 7.0.6
      • The attribute if also has the same issue.

      Workaround

      • use shadow element with boolean operators like <if test="${notExistingVar ne null}"> instead.
      • use stricter syntax like unless = $ {var ne null and var)", if the var is a boolean.
      • add the property below in zk.xml
        <system-property>
            <name>org.zkoss.zel.impl.parser.COERCE_TO_ZERO</name>
            <value>true</value>
        </system-property>	
        

            jumperchen jumperchen
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 30 minutes
                30m