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

org.zkoss.zul.Datebox.setDisplayedTimeZones(List dtzones) NPE if emptied

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 3.6.4, 5.0.11
    • Fix Version/s: 6.5.1
    • Component/s: Components
    • Labels:
    • Environment:

      Not environment dependent.

      Description

      Once you set the displayed TimeZones property of a Datebox you can empty it no more.

      Internal list in component is set to null:

      if (dtzones != null && dtzones.isEmpty())
      	dtzones = null;
      

      Then its size is retrieved:

      for (int i = 0; i < _dtzones.size(); i++) {
      

      And that ends with a NullPointerException.

      org.zkoss.zul.Datebox.setDisplayedTimeZones()
      /**
       * Sets a list of the time zones that will be displayed at the
       * client and allow user to select.
       * <p>If the {@link #getTimeZone()} is null, 
       * the first time zone in the list is assumed.
       * @param dtzones a list of the time zones to display.
       * If empty, it assumed to be null.
       * @since 3.6.3
       */
      public void setDisplayedTimeZones(List dtzones) {
      	if (dtzones != null && dtzones.isEmpty())
      		dtzones = null;
      	if (_dtzones != dtzones) {
      		_dtzones = dtzones;
      		StringBuffer sb = new StringBuffer();
      					// FIXME NPE assured if you empty the list
      		for (int i = 0; i < _dtzones.size(); i++) {
      			if(i != 0) sb.append(",");
      			TimeZone tz = (TimeZone)_dtzones.get(i);
      			sb.append(tz.getID());
      		}
      		smartUpdate("displayedTimeZones", sb.toString());
      		if (_tzone == null && _dtzones != null && _dtzones.get(0) != null)
      			_tzone = (TimeZone)_dtzones.get(0);
      	}
      }	
      

        Attachments

          Activity

            People

            Assignee:
            vincentjian vincentjian
            Reporter:
            motti motti
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: