Hi,
I am developing a plugin for the company I'm employed.
I have successfully created an extension for the global config page that
enables the configuration of endpoints to our OTAP environment that will be
used in a (custom) buildstep.
It is functionally working: I can create, update and delete instances.
Now I want to force uniqueness of the environment name, and possibly other
fields also, across the (already) configured environments.
Does anybody has an idea how I can achieve this?
I've created the validation method in the descriptor but validation always
fails.
Does anyone has an hint or something that I want to achieve?
Many thanks!
Auke
*Groovy snippet:*
def isNew = instance != null
f.entry(field: "name", title: _("Name")) {
f.textbox(value: isNew ? instance.getName() : "")
}
*validation method in descriptor:*
public FormValidation doCheckName(StaplerRequest req, @QueryParameterString
name) {
if (StringUtils.isBlank(name)) {
return FormValidation.error("The name of an endpoint is required");
}
Environment[] environments = getEnvironments();
for (Environment environment : environments) {
if (environment.getName().equals(name)) {
return FormValidation.error("This name is already used for environment \""+
environment.getName() + "\"");
}
}
return FormValidation.ok();
}
The result at the config page is:
<https://lh6.googleusercontent.com/-Z2V-DwlYawI/UsvZLP6KDnI/AAAAAAAAAqs/bDKLDpruywM/s1600/Screen+Shot+2014-01-07+at+11.32.31.png>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.