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

SimpleConstraint created by flag causes JS error

XMLWordPrintable

    • ZK 8.6.1 S1

      Steps to Reproduce

      <zk>
        <zscript><![CDATA[
          Constraint constraintByString = new SimpleConstraint("no empty");
          Constraint constraintByFlag = new SimpleConstraint(SimpleConstraint.NO_EMPTY);
        ]]></zscript>
        working constraint <datebox constraint="${constraintByString}" />
        <separator/>
        failing constraint <datebox constraint="${constraintByFlag}" /> (leaving empty produces JS error)
      </zk>
      

      focus, then blur the dateboxes

      Current Result

      first datebox shows a wrong value message
      second datebox causes a JS error

      zul.inp.wpd:1464 Uncaught TypeError: Cannot read property 'length' of undefined
          at init._init (zul.inp.wpd:1464)
          at init.validate (zul.inp.wpd:1585)
          at init.validate_ (zul.inp.wpd:639)
          at init._validate (zul.inp.wpd:666)
          at init.updateChange_ (zul.inp.wpd:744)
          at init.$supers (zk.wpd:11786)
          at init.updateChange_ (zul.inp.wpd:2037)
          at init.$supers (zk.wpd:11786)
          at init.updateChange_ (zul.db.wpd:3374)
          at init.doBlur_ (zul.inp.wpd:479)
      

      Expected Result

      working constraint validation in both cases, no JS error

      Debug Info

      Root Cause

      side effect of ZK-3527

      Workaround

      	<script><![CDATA[
      	zk.afterLoad('zul.inp', function() {
      		var xSimpleConstraint = {};
      		zk.override(zul.inp.SimpleConstraint.prototype, xSimpleConstraint, {
      			reparseConstraint : function() {
      				if(this._cst) {
      					return xSimpleConstraint.reparseConstraint.apply(this, arguments);
      				}
      			}
      		});//zk.override
      	});//zk.afterLoad
      	]]></script>
      

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

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours
                4h