我可以从global.jelly文件中执行此操作,但不能从config.jelly中执行。下面是global.jelly文件的处理过程:
果冻:
<f:entry title="Value" field="value">
<f:textbox />
</f:entry>JAVA:
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();
}
}当jelly代码放在配置文件(config.jelly)中时,这就不再适用了,不管doCheckValue方法是放在插件类中还是放在它的描述符中。
发布于 2013-02-23 01:01:25
下面是它在config.jelly文件中的变化。textbox有一个额外的属性:checkUrl。
果冻:
<f:entry title="Value" field="value">
<f:textbox
checkUrl="'descriptorByName/NAME_OF_YOUR_JAVA_CLASS/checkValue?value='+escape(this.value)" />
</f:entry>注意:this.value特定于Javascript。它获取value变量的值。别碰它。
Java代码保持不变。
https://stackoverflow.com/questions/15029412
复制相似问题