2012-05-11 37 views
4

我試圖實現我的插件的配置文件時遇到問題。 我開始使用現有的SideBar插件程序,但當我將List<String>作爲變量添加到class Action時,我遇到了一個問題:private List<String> projects; 如何在果凍文件中填充這樣的列表?在jenkins插件的配置jelly文件中填充ArrayList

我試着做這樣:

<f:entry> 
<f:optionalBlock title="Project to be considered :"> 
    <f:repeatable var="project" items="${link.projects}" name="projects" add="Add a project"> 
    <f:entry title="Project 1 :"> 
    </f:entry> 
    </f:repeatable>  
</f:optionalBlock> 
</f:entry> 

我加在links.jelly文件這些行,但它不工作。

如果有人知道如何做到這一點,那就太好了。

謝謝

回答

3

在你的行動清單應該有一個類型(也爲更好的閱讀)

private List<YourObject> projects 

然後你可以config.jelly是這樣的:

<f:repeatable var="projectInList" name="projects" items="${instance.projects}" noAddButton="true" minimum="0"> 
    <fieldset> 
     <f:entry title="${%Project}" description="Project desc." 
           field="variableInProjectObject"> 
      <f:textbox value="${projectInList.variableInProjectObject}" default="" /> 
     </f:entry> 
    </fieldset> 
</f:repeatable> 
0

我用這種方法修復類似問題:

<f:entry title="Parameters" field="projects"> 
    <f:repeatableProperty field="projects" minimum="1" /> 
</f:entry> 

感謝this resource