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

Optional block in jelly has inconsistent behaviour when translated to JSON

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • core
    • None

      // code placeholder
      

      When using an optional block in jelly configuration files, if the checkbox is not checked in the UI, when sent in the Stapler request, sometimes translates to an empty JSON object some other times in a String.

      Example: given the following optional block

      <f:optionalBlock name="enable" title="${%Enable}" checked="${instance != null and instance.count != null}">

      belonging to the java com.example.Property.java class, if it's not checked in the UI, the stapler request can either receive a JSON containing

       

      "com.example.Property":{}}" 
      

      or

      com-example-Property":{"enable":false}

       

       

      When you submit the form, you will get an error like

      JSONObject["someField"] is not a JSONObject

       

            Unassigned Unassigned
            varmenise valentina armenise
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: