How to add list of configurable elements to a Jenkins plugin configuration page?
I have a list of configurable items. It should be able to grow dynamically and each item has 3 fields. There is initially one row, if that is populated I want to add a new empty row.
I have 2 Java files to store the config.
...
public class MainConfigRecorder {
List<CustomConfig> customConfigs;
...
And the customConfig
...
public class CustomConfig {
private String name;
private String pattern;
private String link;
...
public String getLink()
...
public void setLink(String link)
...
...
In the config.jelly I loop through the customConfigs:
...
<j:forEach var="customConfig" items="${config.customConfigs}" indexVar="i">
<f:block>
<table cellspacing="5">
<tr>
<td width="200">
<f:textbox name="customConfig[${i}].name" value="${customConfig.name}" />
...
Problem is when the config is saved! I cannot deserialize it to the Java objects.
I can see this when I inspect the HTML code in browser:
<input name="customIssues[0].name" type="text" class="setting-input " value="">
When the form i ssubmitted and I debug:
public final class GitReleasenotesDescriptor extends BuildStepDescriptor<Publisher> {
...
@Override
public Publisher newInstance(StaplerRequest req, JSONObject formData)
I can see this in formData:
{"fromType":"fromFirstCommit","fromReference":"","toType":"toMaster","toRefeference":"","name":"name","pattern":"pattern","link":"link","stapler-class":"org.jenkinsci.plugins.grl.GitReleasenotesRecorder","kind":"org.jenkinsci.plugins.grl.GitReleasenotesRecorder"}
I did not expect:
..."name":"name","pattern":"pattern","link":"link"...
I was expecting:
..."customIssues": [{ "name":"name","pattern":"pattern","link":"link"}]...
Any suggestions?