Initial select box validation fails when default value is provided.

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major
    • Component/s: core
    • Environment:
      Jenkins version 1.451.
      Jenkins run through mvn hpi:run.
      See system info in attachment for further information.
      Browser: Google Chrome 17 and Firefox 10

      When defining a select box like this:

      <f:entry title="Version Control System type"
              field="vcs">
          <f:select/>
      </f:entry>
      

      and validating the value through a

      int i = 0;
      public FormValidation doCheckVcs(@QueryParameter String value) {
          
          System.out.println(i + ": value: " + value);
          i++;
          try {
              VersionControlSystem.valueOf(value);
              return FormValidation.ok();
          } catch (IllegalArgumentException ex) {
              return FormValidation.error("Please select one of the Version Control Systems.");
          }
      }
      

      method, it can be observed that the validation method is called two times when opening the configuration menu (http://localhost:8080/configure). The first time, the correct default value, i.e., the selected item's value, is passed to the validation method. The second time, no data is passed in (see following code listing for output).

      0: value: MERCURIAL
      1: value: 
      

      The code is additionally available on GitHub:
      Descriptor: https://github.com/bripkens/janus-plugin/blob/389833439d11cc4daf5666c1ac7fb98ecad28471/src/main/java/de/codecentric/janus/plugin/Root.java
      Jelly: https://github.com/bripkens/janus-plugin/blob/389833439d11cc4daf5666c1ac7fb98ecad28471/src/main/resources/de/codecentric/janus/plugin/Root/global.jelly

      Data is provided in the following way:

      public ListBoxModel doFillVcsItems() {
          ListBoxModel m = new ListBoxModel();
          m.add("Please select", "");
      
          for (VersionControlSystem vcs : VersionControlSystem.values()) {
              if (this.vcs == vcs) {
                  m.add(new ListBoxModel.Option(vcs.name(), vcs.name(),
                          true));
              } else {
                  m.add(vcs.name());
              }
              
          }
      
          return m;
      }
      

            Assignee:
            Unassigned
            Reporter:
            Ben Ripkens
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: