Finally, I found a solution with the code of Stephen and some modifications 
in jelly files.

So, I have two class *ZAProxyBuilder* and *ZAProxy* with two *config.jelly*
 respectively.

In the first *config.jelly* file (i.e in the *ZAProxyBuilder* package), I 
include the other file with the following code :

*<f:property field="zaproxy" />*

where *zaproxy* is the name of my member in *ZAProxyBuilder* class. And, in 
this second *config.jelly*, I fill the field normally (i.e with the name of 
member in *ZAProxy* class).

It works perfectly but I don't understand why the following code :

*<st:include page="config.jelly" 
class="fr.novia.zapjenkinsplugin.ZAProxy"/>*

doesn't work. This code includes correctly the second *config.jelly* file 
but it doesn't create a new instance of *ZAProxy* class. If anyone have an 
answer of this problem, i'm interested ;)

Thank you guys for your help.

Regards,
Ludovic.

Le mercredi 8 avril 2015 23:00:44 UTC+2, Ludovic Roucoux a écrit :
>
> 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/6058309a-4c9e-4b8c-a513-8743d4ad0a5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to