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

call ListModelList.add() and a chosenbox throws a javascript error

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Normal
    • 7.0.6
    • 7.0.5, 7.0.5.2
    • None
    • Security Level: Jimmy
    • None

    Description

      Steps to reproduce

      1. run the attached zul and view model
      2. type a non-existed item in the chosenbox, e.g. "bbb" then press enter.

      Actual result

      Javascript error is thrown:

       
      Uncaught TypeError: Cannot read property 'length' of undefined
      zjq.setSelectionRange	@	zk.wpd:12083
      _rsFocus	@	zk.wpd:14963
      zk.Widget.zk.$extends.replaceWidget	@	zk.wpd:15837
      zAu.cmd1.outer.w	@	zk.wpd:20278
      mtAU	@	zk.wpd:18520
      zk.copy.zkx	@	zk.wpd:18680
      zk.copy.zkx_	@	zk.wpd:18696
      zAu.cmd1.outer	@	zk.wpd:20276
      doProcess	@	zk.wpd:19292
      doCmdsNow	@	zk.wpd:19532
      zAu._doCmds	@	zk.wpd:19780
      afterResponse	@	zk.wpd:19424
      onResponseReady	@	zk.wpd:19421
      

      Workaround

      <script type="text/javascript" defer="true"><![CDATA[
       var _xChosenbox = {};
       zk.override(zkmax.inp.Chosenbox.prototype, _xChosenbox, {
      bind_: function() {
      _xChosenbox.bind_.apply(this, arguments);
      zWatch.listen({onResponse: this});
      },
      unbind_: function() {
      zWatch.unlisten({onResponse: this});
      _xChosenbox.unbind_.apply(this, arguments);
      },
      _doEnterPressed: function () {
      _xChosenbox._doEnterPressed.apply(this, arguments);
      this._shallRestoreFocus = zk.currentFocus == this;
      zk.currentFocus = null;
      },
      replaceWidget: function(newwgt) {
      if (this._shallRestoreFocus) {
      newwgt._shallRestoreFocus = true;
      }
      _xChosenbox.replaceWidget.apply(this, arguments);
      },
      onResponse: function() {
      console.log('onResponse', this._shallRestoreFocus);
      if (this._shallRestoreFocus)
      this.$n('inp').focus();
      }
       });
       ]]></script>
      

      Attachments

        1. ChosenboxVM.java
          1 kB
        2. 2805.zul
          0.3 kB

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour
                1h