我可以从 global.jelly 文件中做到这一点,但它不适用于 config.jelly。这是 global.jelly 文件的过程:
果冻:
<f:entry title="Value" field="value">
<f:textbox />
</f:entry>
爪哇:
public static final class Descriptor extends BuildStepDescriptor<Builder>{
//descriptor's code
/**
* Performs on-the-fly validation of the form field 'value'.
*
* @param value
* This parameter receives the value that the user has typed.
* @return Indicates the outcome of the validation. This is sent to the
* browser.
*/
public FormValidation doCheckValue(@QueryParameter String value) throws IOException, ServletException {
if(value.isEmpty()) {
return FormValidation.warning("You must fill this box!");
}
return FormValidation.ok();
}
}
当果冻代码放置在配置文件(config.jelly)中时,这不再适用,无论该doCheckValue
方法是放置在插件类中还是在其描述符中。