Issues with boolean parameter in config.jelly

106 views
Skip to first unread message

gommo

unread,
Jul 28, 2011, 11:48:42 PM7/28/11
to Jenkins Developers
Are there any tricks to getting a boolean parameter for a plugin to
work?

I have this in config.jelly
<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:entry title="${%Application Name}" help="/plugin/crowd/help-
global-appname.html">
<f:textbox name="crowd.applicationName" value="$
{instance.applicationName}" />
</f:entry>
<f:entry title="${%Enabled Single Sign On}" help="/plugin/crowd/
help-global-sso.html">
<f:checkbox name="crowd.ssoEnabled" value="$
{instance.ssoEnabled}" />
</f:entry>
</j:jelly>

and they are declared as public fields in the java backing class.

The string field works fine. If I save then exit and go back in, the
form is populated.
But if I set the checkbox state to ON, and exit and go back in, it is
always unchecked.

The save does work, in that the config.xml has the correct value
Thanks

Bap

unread,
Jul 29, 2011, 4:48:28 AM7/29/11
to jenkin...@googlegroups.com
Quoting gommo <colin....@gmail.com>:

Hi,

You have to write a lot less jelly if you allow the templates in core
do most of the work for you - and it will do the right thing wrt the
checkbox databinding.

<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">

<f:entry title="${%Application Name}" field="applicationName">
<f:textbox/>
</f:entry>
<f:entry title="${%Enabled Single Sign On}" field="ssoEnabled">
<f:checkbox/>
</f:entry>

</j:jelly>

drop a help-applicationName.html and a help-ssoEnabled.html next to
the jelly file, and they will be picked up automatically too.

In your original example, you need to set
checked="${instance.ssoEnabled}" - but I strongly suggest you use the
field databinding example above.

Bap.

gommo

unread,
Jul 30, 2011, 3:33:49 AM7/30/11
to Jenkins Developers
Thanks Bap,

Worked like a charm

On Jul 29, 6:48 pm, Bap <old_ho...@a1.org.uk> wrote:
Reply all
Reply to author
Forward
0 new messages