I'm building a Jenkins plugin that accesses a remote server. As part of the configuration, the user needs to enter a URL for the server and provide an access key. Then the plugin will retrieve a list of resources from the server, and the user needs to select the appropriate one from an html select
input.
I'm using the /lib/form namespace to create the config.jelly
file, and the select is being populated using the tag:
<f:entry title="Resource" field="resource">
<f:select />
</f:entry>
In my Descriptor class, I have a method:
doFillResourceItems(@QueryParamter final String url, @QueryParameter final String key)
and the stapler appears to call the method any time the onchange
event is triggered by the browser (as expected).
My problem is in the doCheckResource(@QueryParameter final String value)
method. It would be helpful to have access to the ListBoxModel
object that was returned by the doFillResourceItems()
method, as the error message I want to display to the user should be different, depending on whether the plugin was able to retrieve the list of resources or not. One option would be to simply inject the url
and key
fields into the doCheckResource
method as well, and try again, but them I'm retrieving the list of resources twice, which isn't ideal.
What do I need to do in order to have Stapler inject that previously retrieved ListBoxModel
object into the validation method call?