Re: kind and stapler-class attributes in JSON form data (since 1.463)

2012-05-15 Thread Johannes Ohlemacher
Hi Chris,
Thanks for your answer, that helped a lot :)

Regards,
Johannes

Am Montag, 14. Mai 2012 14:24:51 UTC+2 schrieb cjo:

 Kind and stapler-class are used by the stapler to bind the configuration 
 section to the correct class (in this case your plugin), this also enabled 
 the stapler to use the Databound constructors of there objects rather than 
 the newInstance method of the descriptor.


 From your code it looks like you don't have a data bound constructor for 
 ValgrindPublisher object. 
 Adding a Databound constructor, and removing the newInstance method from 
 the descriptor may fix the issue. However you may also need change the 
 config.jelly files so that ValgrindPublisherConfig has its own file.

 Example constructor to add:

 @DataBoundConstructor
 public ValgrindPublisher (ValgrindPublisherConfig valgrindPublisherConfig){
 this.valgrindPublisherConfig = valgrindpublisherconfig;
 }


 This change also makes the plugin work correctly with other plugins such 
 as the flexible publish and build condition where it is used as a sub 
 interface, these rely on having a correct DataBoundConstructor.

 Chris


 On Saturday, 12 May 2012 12:36:08 UTC+1, Johannes Ohlemacher wrote:

 Hi everyone,
 since version 1.463 i can't configure the Publisher of my plugin anymore.
 The JSONObject form data contains two strange attributes: kind and 
 stapler-class. Because of those two attributes the StaplerRequest object 
 can't bind the form data to the data bound constructor of my configuration 
 class (or at least thats what i understand, i am still pretty new to 
 jenkins development...).

 The JSONObject looks like this: 
 {failThresholdDefinitelyLost:,
 failThresholdInvalidReadWrite:,
 failThresholdTotal:,
 kind:org.jenkinsci.plugins.valgrind.ValgrindPublisher,
 pattern:*.memcheck,
 stapler-class:org.jenkinsci.plugins.valgrind.ValgrindPublisher,
 unstableThresholdDefinitelyLost:,
 unstableThresholdInvalidReadWrite:,
 unstableThresholdTotal:}

 If i remove the two attributes from the JSONObject before binding it, 
 everything works fine...

 publisher with descriptor (see lines 258 to 266): 
 https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/java/org/jenkinsci/plugins/valgrind/ValgrindPublisher.java
 configuration class: 
 https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/java/org/jenkinsci/plugins/valgrind/config/ValgrindPublisherConfig.java
 jelly file: 
 https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/valgrind/ValgrindPublisher/config.jelly

 Where do the kind and stapler-class attributes come from? They don't 
 appear with older versions of jenkins (i tested 1.455, 1.460 and 1.462).

 Greetings,
 Johannes



Re: kind and stapler-class attributes in JSON form data (since 1.463)

2012-05-14 Thread cjo
Kind and stapler-class are used by the stapler to bind the configuration 
section to the correct class (in this case your plugin), this also enabled 
the stapler to use the Databound constructors of there objects rather than 
the newInstance method of the descriptor.


From your code it looks like you don't have a data bound constructor for 
ValgrindPublisher object. 
Adding a Databound constructor, and removing the newInstance method from 
the descriptor may fix the issue. However you may also need change the 
config.jelly files so that ValgrindPublisherConfig has its own file.

Example constructor to add:

@DataBoundConstructor
public ValgrindPublisher (ValgrindPublisherConfig valgrindPublisherConfig){
this.valgrindPublisherConfig = valgrindpublisherconfig;
}


This change also makes the plugin work correctly with other plugins such as 
the flexible publish and build condition where it is used as a sub 
interface, these rely on having a correct DataBoundConstructor.

Chris


On Saturday, 12 May 2012 12:36:08 UTC+1, Johannes Ohlemacher wrote:

 Hi everyone,
 since version 1.463 i can't configure the Publisher of my plugin anymore.
 The JSONObject form data contains two strange attributes: kind and 
 stapler-class. Because of those two attributes the StaplerRequest object 
 can't bind the form data to the data bound constructor of my configuration 
 class (or at least thats what i understand, i am still pretty new to 
 jenkins development...).

 The JSONObject looks like this: 
 {failThresholdDefinitelyLost:,
 failThresholdInvalidReadWrite:,
 failThresholdTotal:,
 kind:org.jenkinsci.plugins.valgrind.ValgrindPublisher,
 pattern:*.memcheck,
 stapler-class:org.jenkinsci.plugins.valgrind.ValgrindPublisher,
 unstableThresholdDefinitelyLost:,
 unstableThresholdInvalidReadWrite:,
 unstableThresholdTotal:}

 If i remove the two attributes from the JSONObject before binding it, 
 everything works fine...

 publisher with descriptor (see lines 258 to 266): 
 https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/java/org/jenkinsci/plugins/valgrind/ValgrindPublisher.java
 configuration class: 
 https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/java/org/jenkinsci/plugins/valgrind/config/ValgrindPublisherConfig.java
 jelly file: 
 https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/valgrind/ValgrindPublisher/config.jelly

 Where do the kind and stapler-class attributes come from? They don't 
 appear with older versions of jenkins (i tested 1.455, 1.460 and 1.462).

 Greetings,
 Johannes



kind and stapler-class attributes in JSON form data (since 1.463)

2012-05-12 Thread Johannes Ohlemacher
Hi everyone,
since version 1.463 i can't configure the Publisher of my plugin anymore.
The JSONObject form data contains two strange attributes: kind and 
stapler-class. Because of those two attributes the StaplerRequest object 
can't bind the form data to the data bound constructor of my configuration 
class (or at least thats what i understand, i am still pretty new to 
jenkins development...).

The JSONObject looks like this: 
{failThresholdDefinitelyLost:,
failThresholdInvalidReadWrite:,
failThresholdTotal:,
kind:org.jenkinsci.plugins.valgrind.ValgrindPublisher,
pattern:*.memcheck,
stapler-class:org.jenkinsci.plugins.valgrind.ValgrindPublisher,
unstableThresholdDefinitelyLost:,
unstableThresholdInvalidReadWrite:,
unstableThresholdTotal:}

If i remove the two attributes from the JSONObject before binding it, 
everything works fine...

publisher with descriptor (see lines 258 to 266): 
https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/java/org/jenkinsci/plugins/valgrind/ValgrindPublisher.java
configuration class: 
https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/java/org/jenkinsci/plugins/valgrind/config/ValgrindPublisherConfig.java
jelly file: 
https://github.com/jenkinsci/valgrind-plugin/blob/master/src/main/resources/org/jenkinsci/plugins/valgrind/ValgrindPublisher/config.jelly

Where do the kind and stapler-class attributes come from? They don't 
appear with older versions of jenkins (i tested 1.455, 1.460 and 1.462).

Greetings,
Johannes