Check the default radio button in a build-feature form
I'm creating a build-feature plugin, and the form (JSP) with build-feature options has a group of three radio buttons. How can I check the default one?
When the user opens the build-feature options form for the very first time (i.e. after the build feature has just been added to the build config), all the radio buttons are unchecked:
( ) Foo (default)
( ) Bar
( ) Baz
I would like it to come up as follows:
(*) Foo (default)
( ) Bar
( ) Baz
What I've tried so far:
- use the getDefaultParameters() method of my BuildFeature class - I filled in a ("myRadio", "Foo") pair into the map; I saw no effect
- I tried creating a bean extending BasePropertiesBean, because /WEB-INF/tags/props/radioButtonProperty.tag suggests that the default radio button could indeed be checked if I could set propertiesBean.properties[name] (where propertiesBean is a BasePropertiesBean); the plugin then failed to load completely
- I looked at two other plugins that use the radioButtonProperty (here and here) but neither of them seems to concern itself with this
Am I getting close? Any advice appreciated.
Thanks,
Sam
Please sign in to leave a comment.
Hello, Sam.
Please provide the whole piece of code you have tried.
Hi Inna,
I'm attaching the form (feature.jsp).
As explained above, I've tried using the getDefaultParameters() method of my BuildFeature class:
Here's my BuildFeature class:
public class SinCityBuildFeature extends BuildFeature {
...
@Nullable
@Override
public Map<String, String> getDefaultParameters()
{
return new HashMap<String, String>();
}
I've changed it like so:
public class SinCityBuildFeature extends BuildFeature {
...
}
But I have no idea what I'm doing. The documentation is very unclear about the purpose of getDefaultParameters().
I've tried other things too but they didn't lead anywhere so I won't try to reconstruct them here.
I'm attaching a screenshot showing my unchecked radios. Basically my question is how to avoid ever displaying a form with no radio checked.
Thanks,
Sam
Attachment(s):
unchecked radios.PNG
feature.jsp.zip
Hi Sam,
You code (second one and .jsp) looks ok, and should work, afaik.
I've tried with simple build type (see gist) and in TC 9.1.3 all works fine. But as you can see it does not uses other class to store property names.
Also as example you could take a look at rake runner sources, which uses almost same approach (but have dropdowns (select) instaed of radio buttons)
>Basically my question is how to avoid ever displaying a form with no radio checked.
That could be done with some javascript and also by overriding 'jetbrains.buildServer.serverSide.BuildFeature#getParametersProcessor' to ensure something is selected.
PS: Is that code part of SinCity plugin?
Regards,
Vladislav
Hi Vladislav,
Actually you're right, it does work. I don't know what I did differently before... But anyway, case closed. Thanks a lot for investigating this for me!
Best,
Sam
... and yes, it's part of the SinCity plugin.