Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-73518

j:select does not like empty values

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • Jenkins: 2.414.3
      credentials: 1319.v7eb_51b_3a_c97b_

      Reproduction

      Code in Jelly

       

      <f:entry title="${%Test select}" field="testSelect">
          <f:select/>
      </f:entry> 

      Code in Java

       

       

      // in Describable
      private String testSelect;
      
      public String getTestSelect() {
          return testSelect;
      }
      
      @DataBoundSetter
      public void setTestSelect(String testSelect) {
          this.testSelect = testSelect;
      }
      
      // [...]
      
      // in Descriptor
      public ListBoxModel doFillTestSelectItems(@QueryParameter String testSelect){
          ListBoxModel items = new ListBoxModel();
      
          items.add(new ListBoxModel.Option("- none -", "", testSelect.isBlank()));
          items.add(new ListBoxModel.Option("Test 1", "test1", testSelect.equals("test1")));
          items.add(new ListBoxModel.Option("Test 2", "test2", testSelect.equals("test2")));
          items.add(new ListBoxModel.Option("Test 3", "test3", testSelect.equals("test3")));
      
          return items;
      } 

       

       

      Scenario preparation

      • Open the form
      • "- none -" is selected
      • Select test2
      • "test2" is now selected
      • Save and come back OR apply and refresh
      • "test2" is still selected
      • Select test3
      • "test3" is now selected
      • Save and come back OR apply and refresh
      • "test3" is still selected
      • [Now the bug, see attached gif]
      • Select "- none -"
      • (2 rounds of doFill)
      • "test2" is now selected
      • Re-select "- none -"
      • (1 round of doFill, as usual)
      • This time it's working, "- none -" is now selected

       

      It seems due to the special logic included in refillOnChange.

       

      Note: Even if it's especially visible when playing with credentials and the includeEmptyValue() method, the behavior is coming from f:select.

            Unassigned Unassigned
            wfollonier Wadeck Follonier
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: