Skip to content

Commit

Permalink
JENKINS-72505 f:validateButton finds selected radio button
Browse files Browse the repository at this point in the history
  • Loading branch information
timja committed Jan 5, 2024
1 parent 78cdaa9 commit e9b7c0b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 4 additions & 1 deletion test/src/test/java/lib/form/ValidateButtonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,16 @@ public static final class DescriptorImpl extends Descriptor<TestValidateIsCalled

public void doValidateTest1(@QueryParameter("a") String a, @QueryParameter("b") boolean b,
@QueryParameter("c") boolean c, @QueryParameter("d") String d,
@QueryParameter("e") String e) {
@QueryParameter("e") String e,
@QueryParameter("f") String f
) {
try {
assertEquals("avalue", a);
assertTrue(b);
assertFalse(c);
assertEquals("dvalue", d);
assertEquals("e2", e);
assertEquals("f", f);
test1Outcome = null;
} catch (RuntimeException t) {
test1Outcome = t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,27 @@ THE SOFTWARE.
<f:option value="e2" selected="true">e2</f:option>
</select>
</f:entry>
<f:validateButton method="validateTest1" title="test" with="a,b,c,d,e" />

<f:entry title="f">
<f:radioBlock name="f" value="notf" title="fa" checked="false">
<f:entry title="fa">
<f:textbox name="fa"/>
</f:entry>
</f:radioBlock>

<f:radioBlock name="f" value="f" title="fb" checked="true">
<f:entry title="fb">
<f:textbox name="fb"/>
</f:entry>
</f:radioBlock>

<f:radioBlock name="f" value="reallynotf" title="fb" checked="false">
<f:entry title="fc">
<f:textbox name="fc"/>
</f:entry>
</f:radioBlock>
</f:entry>
<f:validateButton method="validateTest1" title="test" with="a,b,c,d,e,f" />
</f:form>
</l:main-panel>
</l:layout>
Expand Down
7 changes: 6 additions & 1 deletion war/src/main/webapp/scripts/hudson-behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -2708,8 +2708,13 @@ function validateButton(checkUrl, paramList, button) {
paramList.split(",").forEach(function (name) {
var p = findPreviousFormItem(button, name);
if (p != null) {
if (p.type == "checkbox") {
if (p.type === "checkbox") {
parameters[name] = p.checked;
} else if (p.type === "radio") {
while (p && !p.checked) {
p = findPreviousFormItem(p, name);
}
parameters[name] = p.value;
} else {
parameters[name] = p.value;
}
Expand Down

0 comments on commit e9b7c0b

Please sign in to comment.