I don't understand why a ZAProxy instance is not created. Anyone can
explain me the @DataBoundConstructor working ?
Le mercredi 8 avril 2015 15:26:02 UTC+2, Ludovic Roucoux a écrit :
>
> Stephen, I tested your code but without more success. The *ZAProxyBuilder
> *constructor is called correctly but not the *ZAProxy *constructor, so my
> *zaproxy
> *in *ZAProxyBuilder *is always *null*.
>
> Le mercredi 8 avril 2015 15:13:01 UTC+2, Stephen Connolly a écrit :
>>
>> You typically want the class you are instatiating to also be a
>> Describable with a Descriptor, so what you want is
>>
>> public class ZAProxy extends AbstractDescribableImpl<ZAProxy> {
>>
>> ...
>>
>> @Extension
>> public static class DescriptorImpl extends Descriptor<ZAProxy> {
>> public String getDisplayName() { return null; }
>> }
>> }
>>
>> On 8 April 2015 at 11:21, Ludovic Roucoux <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> I develop a build step plugin and I try to bind an object composed of an
>>> other object. Here it's what i have :
>>>
>>> *public class ZAProxyBuilder extends Builder {*
>>>
>>> private final ZAProxy zaproxy;
>>>
>>> private final boolean startZAPFirst;
>>>
>>> // Fields in config.jelly must match the parameter names in the
>>> "DataBoundConstructor"
>>> @DataBoundConstructor
>>> public ZAProxyBuilder(boolean startZAPFirst, ZAProxy zaproxy) {
>>>
>>> this.startZAPFirst = startZAPFirst;
>>>
>>> this.zaproxy = zaproxy;
>>>
>>> }
>>>
>>>
>>>
>>> public boolean getStartZAPFirst() {
>>>
>>> return startZAPFirst;
>>>
>>> }
>>> public ZAProxy getZaproxy() {
>>>
>>> return zaproxy;
>>>
>>> }
>>>
>>> *}*
>>>
>>> *public class ZAProxy {*
>>>
>>> private final String targetURL;
>>> private final boolean spiderURL;
>>>
>>> @DataBoundConstructor
>>> public ZAProxy(String targetURL, boolean spiderURL) {
>>>
>>> this.targetURL = targetURL;
>>>
>>> this.spiderURL = spiderURL;
>>>
>>> }
>>>
>>>
>>>
>>> public String getTargetURL() {
>>>
>>> return targetURL;
>>>
>>> }
>>> public boolean getSpiderURL() {
>>>
>>> return spiderURL;
>>>
>>> }
>>>
>>> *}*
>>>
>>> And my *config.jelly* in *src/main/resources/ZAProxyBuilder*
>>> <?jelly escape-by-default='true'?>
>>> <j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler"
>>> xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson"
>>> xmlns:f="/lib/form">
>>>
>>> <f:optionalBlock title="${%Start ZAProxy in a pre-build step}"
>>> field="startZAPFirst" inline="true" />
>>>
>>> <f:entry title="${%Target URL}" >
>>>
>>> <f:textbox name="zaproxy.targetURL"
>>> value="${instance.zaproxy.targetURL}" clazz="required" />
>>>
>>> </f:entry>
>>>
>>>
>>>
>>> <f:optionalBlock title="${%Spider URL}"
>>> field="${instance.zaproxy.spiderURL}" inline="true" />
>>>
>>> </j:jelly>
>>>
>>>
>>> The value of *startZAPFirst* is saved but not the values of the ZAProxy
>>> class. The constrcutor of ZAProxy is never called.
>>> I also try to write a second config.jelly in *src/main/resources/ZAProxy
>>> *and include this file to the *config.jelly* in
>>> *src/main/resources/ZAProxyBuilder* like this :
>>>
>>> *<st:include page="config.jelly" class="${ZAProxy}"/>*
>>> but without success.
>>>
>>> Anyone can help me ?
>>>
>>> Regards,
>>> Ludovic.
>>>
>>> --
>>> 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/9135d836-28e0-4e79-93d9-9c4ecea4fdcb%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/jenkinsci-dev/9135d836-28e0-4e79-93d9-9c4ecea4fdcb%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
--
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/b0e1cc2f-a6eb-4555-b27a-62df603cd15c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.