Class FormFillFailure

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
com.oracle.cloud.baremetal.jenkins.FormFillFailure
All Implemented Interfaces:
Serializable, org.kohsuke.stapler.HttpResponse

public class FormFillFailure extends IOException implements org.kohsuke.stapler.HttpResponse
Helper for hudson.util.FormFillFailure, which was not added until JENKINS-42443, which was added in Jenkins 2.50. If an older version of Jenkins is being used at runtime, then a fallback implementation is used.

Sample usage

   public class TheClass {
     @DataBoundConstructor
     public TheClass(String theField) {
       // Decode in case the control form had an encoded error.
       this.theField = FormFillFailure.getErrorValue(theField);
     }

     public class DescriptorImpl ... {
       public ListBoxModel doFillTheFieldItems(@QueryParameter String theField) throws FormFillFailure {
         // Decode in case the control form had an encoded error.
         theField = FormFillFailure.getErrorValue(theField);
         if (...error...) {
           throw FormFillFailure.error(...message..., theField);
         }

         // Add an empty value to require selection.
         ListBoxModel model = new ListBoxModel().add("");

         // Explicitly set the selected parameter in case the control form
         // value had an encoded error with this value.
         model.add(new ListBoxModel.Option(displayName, value, value.equals(theField)));

         return model;
       }

       public FormValidation doCheckTheField(@QueryParameter String theField) {
         // Decode in case the control form had an encoded error without
         // a selected value.
         return FormFillFailure.validateRequired(value);
       }
     }
   }
 
See Also: