Hi Jesse,
Thanks for the suggestion. I have adapted my code to follow the HeteroList
approach. However, I am still facing some issues when I try to use a base
class to wrap some common parameters (i.e: debug mode) while delegating to
child classes the specific ones. I was trying to adapt first the HeteroList
example to see how could I achieve it. I have modified the Entry class as
follows:
public static class Entry extends AbstractDescribableImpl<Entry> {
private Boolean debug;
@DataBoundConstructor
public Entry(){}
public Boolean getDebug() {
return debug;
}
@DataBoundSetter
public void setDebug(Boolean debug) {
this.debug = debug;
}
I added within the resources/jenkins/plugins/ui_samples/HeteroList/ a
folder named Entry with the following config.jelly:
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="">
<f:checkbox field="debug" title="Debug mode?"/>
</f:entry>
</j:jelly>
I was expecting that these changes would allow me to add the debug
parameter to all 3 child classes of the Entry class (using the
DataBoundConstructor associated to the parent class). I am not sure if this
is possible, or what approach should I take. Any guidance or example would
be appreciated.
Thanks again for your time and help
BRs
/Iván
El viernes, 5 de marzo de 2021 a las 21:02:23 UTC+1, Jesse Glick escribió:
> On Fri, Mar 5, 2021 at 10:14 AM Ivan Martinez <[email protected]>
> wrote:
>
>> I have seen that a different type of object can be referenced, which is
>> the ${instance}. I have tried by modifying the references to ${it} and
>> replace them by ${instance}. In this case, it does refer to the
>> HelloWorldBuilder class, but, this object is null when adding the build
>> step into a job for the first time. Once I save the job and re-configure,
>> the drop-down list is populated, since the instance is created.
>>
>
> Right, `instance` is set only during reconfiguration. `descriptor` is
> always set.
>
> If you are using high-level form controls, you should normally need to pay
> attention to `it` and `instance`. `descriptor` would be used for example to
> let you load a list of options from Java (your `DescriptorImpl`).
>
> the data does not seem to be persisted, I have debugged and indeed the
>> DataBoundConstructor for HelloWorldBuilder is invoked and the Fruit object
>> is passed to it, but in further re-configurations of the job step, it is
>> not persisted.
>>
>
> Check whether the actual `config.xml` is saved correctly.
>
> I think your issue is that you are looking at the `DropdownList` example,
> which is using low-level form controls. For the purposes of typical
> plugins, you can ignore all that. The `HeteroList` example is more relevant
> (specifically the objects *inside* it starting with `Config`). Basically
> use controls which have a `field` attribute.
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jenkinsci-dev/bcf04a87-91b3-426c-8706-fca3060b72bbn%40googlegroups.com.