Global settings, doFillXYZItems and previously stored settings

27 views
Skip to first unread message

Thiago Lima

unread,
Jul 23, 2015, 8:38:14 PM7/23/15
to Jenkins Developers
I managed to corretly save my plugin global settings to the XML file, but I'm stuck on how to fill correctly the global settings view, since my <select> is being filled with the help of a "doFillXYZItems" method. I saw the "selected" property in the Option object, but I don't know how to get the stored setting for the input I'm rendering. The jelly code and fill method are right below.

<f:entry title="Repositories" field="repositories">
   <f:repeatable var="repo" minimum="1" items="${descriptor.repositories}" add="Add repository">
      <table width="100%" style="margin-bottom: 3px">
         <f:entry title="Type" field="type">
            <f:select />
         </f:entry>

         <f:entry title="Name" field="name">
            <f:textbox value="${repo.name}" />
         </f:entry>

         <f:entry title="URL" field="url">
            <f:textbox value="${repo.url}" />
         </f:entry>

         <f:entry title="">
            <div align="right">
               <f:repeatableDeleteButton value="Delete" />
            </div>
         </f:entry>
      </table>
   </f:repeatable>
</f:entry


public ListBoxModel doFillTypeItems() {
   ListBoxModel ret = new ListBoxModel();

   for (RepositoryType o : RepositoryType.values()) {
      ret.add(o.getDescription(), o.name());
   }

   return ret;
}


Oleg Nenashev

unread,
Jul 26, 2015, 7:06:32 AM7/26/15
to Jenkins Developers, t.au...@gmail.com
Hello Thiago,

Seems you are using an old forms API, which I would not recommend for new plugins. The right way would be to get rid of f:repeatable and...
1) Move configurations to RepositoryType, make it Describable
2) Optional: make RepositoryType an extension point to make the behavior flexible
3) Define configs on the RepositoryType level
4) use f:repeatableProperty or f:hetero-list

Such approach will make your plugin configuration much more flexible.

Best regards,
Oleg

пятница, 24 июля 2015 г., 3:38:14 UTC+3 пользователь Thiago Lima написал:
Reply all
Reply to author
Forward
0 new messages