@QueryParameter in form validation is not filled for dropdownDescriptorSelector

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

@QueryParameter in form validation is not filled for dropdownDescriptorSelector

Ulli Hafner
I’m trying to use form validation on a dropdownDescriptorSelector, however here the validation method parameters (annotated with @QueryParameter) are not found and set to null (or 0). (If used standalone the validation works).

Is there anything different with a dropdownDescriptorSelector?

The relevant main jelly part:

<f:entry description="${description.tool}">
        <f:dropdownDescriptorSelector field="tool" title="${%title.tool}"
                descriptors="${descriptor.availableTools}"/>
</f:entry>

The relevant jelly part of the referenced Describable:

<f:entry title="${%High priority threshold}"
         description="${%Minimum number of duplicated lines for high priority warnings.}"
         field="highThreshold">
  <f:textbox default="50"/>
</f:entry>

My validation method:

public FormValidation doCheckHighThreshold(@QueryParameter final int highThreshold,
        @QueryParameter final int normalThreshold) {
    return VALIDATION.validateHigh(highThreshold, normalThreshold);
}

Both parameters are always set to zero when setting a breakpoint here.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/C2537DD2-FB97-4B57-A972-14643BD727B1%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc (540 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: @QueryParameter in form validation is not filled for dropdownDescriptorSelector

Jesse Glick-4
On Wed, Mar 21, 2018 at 3:53 PM, Ullrich Hafner
<[hidden email]> wrote:
> Is there anything different with a dropdownDescriptorSelector?

No, it should work.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1MAavT6qERsd7MbgqertN91wxecedYiw0MUZm%2BdUAYyg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @QueryParameter in form validation is not filled for dropdownDescriptorSelector

Ulli Hafner
Ok, thanks. I created an issue: JENKINS-50355. Maybe the problem is that the views are in different plugins and are loaded by different class loaders...

> Am 21.03.2018 um 23:27 schrieb Jesse Glick <[hidden email]>:
>
> On Wed, Mar 21, 2018 at 3:53 PM, Ullrich Hafner
> <[hidden email]> wrote:
>> Is there anything different with a dropdownDescriptorSelector?
>
> No, it should work.
>
> --
> 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 [hidden email].
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1MAavT6qERsd7MbgqertN91wxecedYiw0MUZm%2BdUAYyg%40mail.gmail.com.
> 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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/A0200A39-1F1D-40FF-A614-C965A8281631%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc (540 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: @QueryParameter in form validation is not filled for dropdownDescriptorSelector

Jesse Glick-4
On Thu, Mar 22, 2018 at 7:05 PM, Ullrich Hafner
<[hidden email]> wrote:
> I created an issue: JENKINS-50355.

Most likely some typo or other bug in your plugin code, but hard to
know offhand. If there a simple way to reproduce this problem locally,
state that in the issue.

> Maybe the problem is that the views are in different plugins and are loaded by different class loaders...

Should not matter.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3cDq%3D3_Jjzt%3DJRcsbmdZ4wja75qY%2BqFzRJ314Z4cMhRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @QueryParameter in form validation is not filled for dropdownDescriptorSelector

Ulli Hafner
I finally managed it to get it fixed (at least in my plugin). I think there still I a bug in Stapler here:

If I define the validation method using:
public FormValidation doCheckHighThreshold(@QueryParameter final int highThreshold,
@QueryParameter final int normalThreshold) {
return VALIDATION.validateHigh(highThreshold, normalThreshold);
}
then in the generated HTML the attribute checkdependson is empty:

<input checkdependson="" default="50" checkurl="/view/White%20Mountains/job/New%20-%20Pipeline%20-%20Model/pipeline-syntax/descriptorByName/cpd/checkHighThreshold" name="_.highThreshold" type="text" class="setting-input validated  " value="50">

If I rather use 
public FormValidation doCheckHighThreshold(@QueryParameter(value = "highThreshold") final int highThreshold,
@QueryParameter(value = "normalThreshold") final int normalThreshold) {
return VALIDATION.validateHigh(highThreshold, normalThreshold);
}
Then in the generated HTML the attribute checkdependson is correct:

<input checkdependson="highThreshold normalThreshold" default="50" checkurl="/view/White%20Mountains/job/New%20-%20Pipeline%20-%20Model/pipeline-syntax/descriptorByName/cpd/checkHighThreshold" name="_.highThreshold" type="number" class="setting-input validated " value="50">

From the documentation of @QueryParameter: if value is not given, then the name of the parameter should be used.

Am 23.03.2018 um 15:25 schrieb Jesse Glick <[hidden email]>:

On Thu, Mar 22, 2018 at 7:05 PM, Ullrich Hafner
<[hidden email]> wrote:
I created an issue: JENKINS-50355.

Most likely some typo or other bug in your plugin code, but hard to
know offhand. If there a simple way to reproduce this problem locally,
state that in the issue.

Maybe the problem is that the views are in different plugins and are loaded by different class loaders...

Should not matter.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3cDq%3D3_Jjzt%3DJRcsbmdZ4wja75qY%2BqFzRJ314Z4cMhRg%40mail.gmail.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/7E4CC619-5913-4D52-A7F7-4D82C93E1A23%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc (499 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: @QueryParameter in form validation is not filled for dropdownDescriptorSelector

Jesse Glick-4
On Thu, Feb 14, 2019 at 5:55 PM Ullrich Hafner <[hidden email]> wrote:
> I think there still I a bug in Stapler here

Does look that way. Please file it, and of course if you can track
down the cause a PR would be great.

The only thing unusual I see about your example is the use of `int`,
where most check methods would be accepting `String`s.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3G_KpFqw%2Bz_B6TtkDGT%2BKHLaCJ%3D_dWSDAdQj06XwRxFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: @QueryParameter in form validation is not filled for dropdownDescriptorSelector

Ulli Hafner


Am 15.02.2019 um 05:05 schrieb Jesse Glick <[hidden email]>:

On Thu, Feb 14, 2019 at 5:55 PM Ullrich Hafner <[hidden email]> wrote:
I think there still I a bug in Stapler here

Does look that way. Please file it, and of course if you can track
down the cause a PR would be great.


(Is there no component for Stapler).

I found the root cause now as well. Stapler does not detect the parameter names since the validation methods are part of a non/public abstract class. There should be some warning or error printed by Stapler. 
Where is this part of the code located? 


The only thing unusual I see about your example is the use of `int`,
where most check methods would be accepting `String`s.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3G_KpFqw%2Bz_B6TtkDGT%2BKHLaCJ%3D_dWSDAdQj06XwRxFg%40mail.gmail.com.
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/F281E93D-41F0-4B5A-8E85-A402DA3CB274%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

signature.asc (499 bytes) Download Attachment