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

Initial select box validation fails when default value is provided.

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • 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
    • Similar Issues:

      Description

      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;
      }
      

        Attachments

          Activity

          bripkens Ben Ripkens created issue -
          jorgenpt Jørgen Tjernø made changes -
          Field Original Value New Value
          Assignee Jørgen Tjernø [ jorgenpt ]
          Component/s jenkins-plugin-runtime [ 16320 ]
          oleg_nenashev Oleg Nenashev made changes -
          Component/s core [ 15593 ]
          Component/s plugin-proposals [ 15491 ]
          rtyler R. Tyler Croy made changes -
          Workflow JNJira [ 143260 ] JNJira + In-Review [ 175853 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              bripkens Ben Ripkens
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: