Help with Jelly for Global Config

13 views
Skip to first unread message

Miguel Campos

unread,
Sep 30, 2020, 9:52:25 AM9/30/20
to Jenkins Developers

Hello guys I need some help with a form for the global config.

I'm trying to modify the default config sample plugin and mixing it with the samples of the UI-sample plugin.

so finaly I can create my own configuration for my plugin.
but I'm really strugling.

This is the Jelly file.

-----------
file name: config.jelly
in package: io.jenkins.plugins.sample.SampleConfiguration
---------------
<?xml version="1.0" encoding="UTF-8"?>
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s="/lib/samples">
    <f:section title="${%01Test Form}">
        <f:entry field="label" title="${%Label}">
            <f:textbox/>
        </f:entry>
        <j:set var="currentFruit" value="${it.fruit}" defaultValue="noneRamone"/>
        <f:block>Esta es mi current Fruit "${currentFruit.displayName}"</f:block>
        <f:dropdownList name="fruit" title="Fruits">
          <j:forEach var="descriptor" items="${it.fruitDescriptors()}" varStatus="loop">
            <j:set var="fruit" value="${descriptor==currentFruit.descriptor?currentFruit:null}"/>
            <f:dropdownListBlock title="${descriptor.displayName}" value="${loop.index}"
                                 selected="${fruit!=null}" staplerClass="${descriptor.clazz.name}">
              <st:include page="${descriptor.configPage}" class="${descriptor.clazz}"/>
            </f:dropdownListBlock>
          </j:forEach>
        </f:dropdownList>

    </f:section>
</j:jelly>
-----------------


The thing is for the textbox label it get the information from the Java class right.
but for the j:set current Fruit  I gues it should execute the method get Fruit() from the same class but it does not.
I have traces and the method is never executed.

I'm lost no idea what I'm doing wrong
I guess the same is happening for the j:forEach to fullfill all the options inthe dropdown list.

any ideas?

I must admit I have verry little jelly knowledge and I'm also struging to find documentation that helps with this.

Thanks for your help.

Ullrich Hafner

unread,
Sep 30, 2020, 11:19:40 AM9/30/20
to Jenkins Developers
How should your configuration look like? What values should be changed by the user?

--
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 jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/4766705e-6cce-4e56-b04d-6a3997e21f07n%40googlegroups.com.

Miguel Campos

unread,
Sep 30, 2020, 12:29:15 PM9/30/20
to Jenkins Developers
Hi I'm trying to replecate (at the moment) the sample of the Dropdown List Sample that the UI samples plugin have.
but instead in a separated page. in the global configuration.

So at the moment the form shoul look like
in the section for my plugin.
1 text box for property Label. (this is working fine)
2 then I want to have a dropdownList   that select the two fruit clases I have apple and Banana (same as in the ussample)
and based on that show a different form .

but as I said my drop list is emplty and the methods inside the java class for Sampleconfiguration are not beeing called.
they are called only for the first text box.
 but all the rest of the jelly code is like it was not there. I see an empty droplist.
I'm lost I do not know if the "it" object is not working or what is happening.

Sorry for the bad explanation.I know it is verry difficult to help mi with this little info. sorry.

should be something like this but in the global config section and with a text field on top called label.

The Seeds form is dynamic and changes based on the content of the droplist.

Reply all
Reply to author
Forward
0 new messages