Stapler Data Binding with Heterogeneous component

16 views
Skip to first unread message

Allan Burdajewicz

unread,
Oct 1, 2019, 7:24:46 AM10/1/19
to Jenkins Developers
Hello Folks,

I am trying to put in place an abstraction layer to create UI components that are meant to be used on AbstractItem, Run and Computer actions. Those components do not need to be persisted / saved anywhere and are just information for the actual action POST. 

I use a jelly /lib/form/descriptorList to display the components. And the UI is working as expected.

On the Action POST method however, I want to retrieve the list of configured components (to a list of my abstract component) and therefore I cannot use the bindJSONToList method on the StaplerRequest as it would fail with: org.kohsuke.stapler.NoStaplerConstructorException: There's no @DataBoundConstructor on any constructor of class com.cloudbees.jenkins.support.components.AbstractComponent

I am not sure what is the right / best way for doing this ? Or maybe I do have to parse the JSON myself ? 

I have pushed the scenario to https://github.com/Dohbedoh/jenkins-extension-action-test to help understand what I am trying to do.

Any guidance / pointers would help.

Thanks!

Jesse Glick

unread,
Oct 1, 2019, 8:49:04 AM10/1/19
to Jenkins Dev
On Tue, Oct 1, 2019 at 7:24 AM Allan Burdajewicz
<aburda...@cloudbees.com> wrote:
> I use a jelly /lib/form/descriptorList to display the components.

Does not sound right. That is a low-level control. I think you meant
to use a high-level control such as `repeatableHeteroProperty`.

Allan Burdajewicz

unread,
Oct 2, 2019, 6:52:37 AM10/2/19
to Jenkins Developers
Thanks Jesse.

I am really looking for having the components listed in a similar way that Node Properties or Job Properties are displayed, a list of checkboxes that render the component descriptor once checked. Hence the choice for "descriptorList". Also in that particular case I do not need to persist the configuration that is POSTed. Just need to bind it to Java objects to perform the action.

Reply all
Reply to author
Forward
0 new messages