Reputation: 2933
I am trying to get form validation for my Jenkins plugin.
This is my plugin java source. it's a SimpleBuildStep where someone must put in an ID in my form. I'm just trying to get it to work. When I empty out the field, nothing happens.
public class WATSBuilder extends hudson.tasks.Builder implements SimpleBuildStep {
private String suvId;
private String suvPassword;
@Extension
public static class Descriptor extends BuildStepDescriptor<hudson.tasks.Builder> {
@Override
public boolean isApplicable(Class<? extends AbstractProject> jobType) {
return FreeStyleProject.class.isAssignableFrom(jobType);
}
@Override
public String getDisplayName(){
return "Jetson WATS Plugin";
}
public FormValidation doChecksuvId(@QueryParameter String value, @AncestorInPath AbstractProject project) {
if( value.isEmpty() ){
return FormValidation.error("There's a problem here");
} else {
return FormValidation.ok();
}
}
.
.
.
}
This is my jelly config:
<f:section title="Environment">
<f:radioBlock title="SUV" value="suv" checked="${instance.isSUVEnv('suv')}" name="env" inline="true">
<f:entry title="SUV ID" field="suvId" >
<f:textbox default="i-xxxxxxxxxxxx" />
<!-- checkUrl="'${rootURL}/plugin/jetson/checkSuvid?val='+this.value" -->
</f:entry>
</f:radioBlock>
<f:radioBlock title="Other" value="other" checked="${instance.isSUVEnv('other')}" name="env" inline="true">
<f:entry title="Endpoint" field="watsEndpoint">
<f:textbox/>
</f:entry>
</f:radioBlock>
</f:section>
Upvotes: 0
Views: 868
Reputation: 33936
You need to capitalize the field name, so doCheckSuvId
, not doChecksuvId
.
Upvotes: 1