Converting existing hetero-list to repeatableHeteroProperty to take advantage of data binding

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Converting existing hetero-list to repeatableHeteroProperty to take advantage of data binding

Gregory Paciga
I'm trying to re-work some existing plugin code to take advantage of data binding, with the end goal of being able to use the configuration-as-code plugin to configure it. A piece I'm stuck on is that a hetero-list is being used to configure a DescribableList, populating it with instances of 2 different classes. I think I need to convert this into a repeatableHeteroProperty, but I can't figure out how to change the classes to get data binding working.
So far, just setting the field attribute to point to the existing DescribableList doesn't work; it renders an "Add" button, but the dropdown list to choose which class to add is empty.

I've looked at several plugin implementations that seem to suggest the instead of a DescribableList, the repetableHeteroProperty field should point to a List<>. When trying that, I get an error that the plugin class's Descriptor list is null:

WARNING h.ExpressionFactory2$JexlExpression#evaluate: Caught exception evaluating: h.filterDescriptors(it,attrs.descriptors) in /jenkins/configure. Reason: java.lang.NullPointerException: Descriptor list is null for context 'class org.jenkinsci.plugins.heterobinding.HeteroBinding' in thread 'Handling GET /jenkins/configure from 127.0.0.1 : qtp884287375-18 Jenkins/configure.jelly HeteroBinding/config.jelly'
java.lang.NullPointerException: Descriptor list is null for context 'class org.jenkinsci.plugins.heterobinding.HeteroBinding' in thread 'Handling GET /jenkins/configure from 127.0.0.1 : qtp884287375-18 Jenkins/configure.jelly HeteroBinding/config.jelly'

I have a feeling I'm getting confused by the fact that this property is on a class that extends Plugin, and it doesn't have a DataBoundConstructor, whereas all the examples I've found extend AbstractDescribableImpl. I've tried moving the list to its own class that extends AbstractDescribableImpl, but I end up with the same error.

This thread is obviously relevant, but I wasn't able to wrap my head around what was happening in the linked code or how it could map onto my code.

Since I'm a novice at Jenkins plugins development, and I'm not sure what the right approach even is here, I've put together a complete but simplified example of my starting point here: https://github.com/gpaciga/jenkins-hetero-data-binding

I would greatly appreciate it if someone could take a look and point me in the right direction.



--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/744a2131-f447-4425-83a0-3eb1586083c6n%40googlegroups.com.