Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何将config.jelly上的复选框与生成器类绑定?_Java_Jenkins_Jenkins Plugins_Jelly - Fatal编程技术网

Java 如何将config.jelly上的复选框与生成器类绑定?

Java 如何将config.jelly上的复选框与生成器类绑定?,java,jenkins,jenkins-plugins,jelly,Java,Jenkins,Jenkins Plugins,Jelly,这是基于HelloWorldBuilder的生成器类 public class LogInfoBuilder extends Builder { private final TimerSettings settings = new TimerSettings(); private final List<String> infoCollection = new ArrayList<String>(); // Fields in config.je

这是基于HelloWorldBuilder的生成器类

public class LogInfoBuilder extends Builder {
    private final TimerSettings settings = new TimerSettings();

    private final List<String> infoCollection = new ArrayList<String>();

    // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
    @DataBoundConstructor
    public LogInfoBuilder(String key, boolean isStart) {
        settings.setKey(key);
        settings.setIsStart(isStart);
    }

    /**
     * We'll use this from the <tt>config.jelly</tt>.
     */
    public String getKey() {
        return settings.getKey();
    }

    public boolean isStart()
    {
        return settings.getIsStart();
    }

    ...
LogInfoBuilder扩展了公共类{
私有最终TimerSettings设置=新TimerSettings();
private final List infoCollection=new ArrayList();
//config.jelly中的字段必须与“DataBoundConstructor”中的参数名称匹配
@数据边界构造函数
公共LogInfoBuilder(字符串键,布尔isStart){
设置。设置键(键);
settings.setIsStart(isStart);
}
/**
*我们将从config.jelly中使用它。
*/
公共字符串getKey(){
返回设置;
}
公共布尔值isStart()
{
返回设置;
}
...
这是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">
  <!--
    This jelly script is used for per-project configuration.

    See global.jelly for a general discussion about jelly script.
  -->

  <!--
    Creates a text field that shows the value of the "name" property.
    When submitted, it will be passed to the corresponding constructor parameter.
  -->
  <f:entry title="Key" field="key">
    <f:textbox />
  </f:entry>

  <!--
  <f:entry title="Start?" field="isstart">
    <select name="isStart">
      <option value="true" selected="${it.isstart}">Yes</option>
      <option value="false" selected="${!it.isstart}">No!</option>
    </select>
  </f:entry>
  -->

  <f:entry title="Starting point?" description="If checked, this will be the starting point.">
    <f:checkbox name="start" checked="${it.start}"/>
  </f:entry>
</j:jelly>

该复选框显示在作业配置页面上,但我无法从中设置值,我的意思是,选中或取消选中该页面上的复选框不会影响生成器类中的值

这是配置页面,ui正确呈现。

但是输出不是我期望的,即使我选中复选框,它也总是
false


我在生成器和/或jelly文件中做错了什么?

您似乎有两个复选框??或者您正试图在一个jelly复选框旁边创建自己的复选框

config.jelly
中有整个部分:

<f:entry title="Start?" field="isstart">
<select name="isStart">
  <option value="true" selected="${it.isstart}">Yes</option>
  <option value="false" selected="${!it.isstart}">No!</option>
</select>
</f:entry>

正如你所看到的,我删除了中间的无用部分,并更改了定义复选框的方式。

然后将LogInfoBuilder更改为:

public class LogInfoBuilder extends Builder {
    private final TimerSettings settings = new TimerSettings();

    private final List<String> infoCollection = new ArrayList<String>();

    // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
    @DataBoundConstructor
    public LogInfoBuilder(String key, boolean start) {
        settings.setKey(key);
        settings.setIsStart(start);
    }

    /**
     * We'll use this from the <tt>config.jelly</tt>.
     */
    public String getKey() {
        return settings.getKey();
    }

    public boolean isStart()
    {
        return settings.getIsStart();
    }

    ...
LogInfoBuilder扩展了公共类{
私有最终TimerSettings设置=新TimerSettings();
private final List infoCollection=new ArrayList();
//config.jelly中的字段必须与“DataBoundConstructor”中的参数名称匹配
@数据边界构造函数
公共LogInfoBuilder(字符串键,布尔开始){
设置。设置键(键);
settings.setIsStart(开始);
}
/**
*我们将从config.jelly中使用它。
*/
公共字符串getKey(){
返回设置;
}
公共布尔值isStart()
{
返回设置;
}
...

这些更改只包括更改变量的名称以适应config.jelly中给出的名称。

您似乎有两个复选框??或者您正试图在一个jelly复选框旁边创建自己的复选框

config.jelly
中有整个部分:

<f:entry title="Start?" field="isstart">
<select name="isStart">
  <option value="true" selected="${it.isstart}">Yes</option>
  <option value="false" selected="${!it.isstart}">No!</option>
</select>
</f:entry>

正如你所看到的,我删除了中间的无用部分,并更改了定义复选框的方式。

然后将LogInfoBuilder更改为:

public class LogInfoBuilder extends Builder {
    private final TimerSettings settings = new TimerSettings();

    private final List<String> infoCollection = new ArrayList<String>();

    // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
    @DataBoundConstructor
    public LogInfoBuilder(String key, boolean start) {
        settings.setKey(key);
        settings.setIsStart(start);
    }

    /**
     * We'll use this from the <tt>config.jelly</tt>.
     */
    public String getKey() {
        return settings.getKey();
    }

    public boolean isStart()
    {
        return settings.getIsStart();
    }

    ...
LogInfoBuilder扩展了公共类{
私有最终TimerSettings设置=新TimerSettings();
private final List infoCollection=new ArrayList();
//config.jelly中的字段必须与“DataBoundConstructor”中的参数名称匹配
@数据边界构造函数
公共LogInfoBuilder(字符串键,布尔开始){
设置。设置键(键);
settings.setIsStart(开始);
}
/**
*我们将从config.jelly中使用它。
*/
公共字符串getKey(){
返回设置;
}
公共布尔值isStart()
{
返回设置;
}
...

这些更改只包括更改变量的名称以适应config.jelly中给出的名称。

您似乎有两个复选框??或者您正试图在一个jelly复选框旁边创建自己的复选框

config.jelly
中有整个部分:

<f:entry title="Start?" field="isstart">
<select name="isStart">
  <option value="true" selected="${it.isstart}">Yes</option>
  <option value="false" selected="${!it.isstart}">No!</option>
</select>
</f:entry>

正如你所看到的,我删除了中间的无用部分,并更改了定义复选框的方式。

然后将LogInfoBuilder更改为:

public class LogInfoBuilder extends Builder {
    private final TimerSettings settings = new TimerSettings();

    private final List<String> infoCollection = new ArrayList<String>();

    // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
    @DataBoundConstructor
    public LogInfoBuilder(String key, boolean start) {
        settings.setKey(key);
        settings.setIsStart(start);
    }

    /**
     * We'll use this from the <tt>config.jelly</tt>.
     */
    public String getKey() {
        return settings.getKey();
    }

    public boolean isStart()
    {
        return settings.getIsStart();
    }

    ...
LogInfoBuilder扩展了公共类{
私有最终TimerSettings设置=新TimerSettings();
private final List infoCollection=new ArrayList();
//config.jelly中的字段必须与“DataBoundConstructor”中的参数名称匹配
@数据边界构造函数
公共LogInfoBuilder(字符串键,布尔开始){
设置。设置键(键);
settings.setIsStart(开始);
}
/**
*我们将从config.jelly中使用它。
*/
公共字符串getKey(){
返回设置;
}
公共布尔值isStart()
{
返回设置;
}
...

这些更改只包括更改变量的名称以适应config.jelly中给出的名称。

您似乎有两个复选框??或者您正试图在一个jelly复选框旁边创建自己的复选框

config.jelly
中有整个部分:

<f:entry title="Start?" field="isstart">
<select name="isStart">
  <option value="true" selected="${it.isstart}">Yes</option>
  <option value="false" selected="${!it.isstart}">No!</option>
</select>
</f:entry>

正如你所看到的,我删除了中间的无用部分,并更改了定义复选框的方式。

然后将LogInfoBuilder更改为:

public class LogInfoBuilder extends Builder {
    private final TimerSettings settings = new TimerSettings();

    private final List<String> infoCollection = new ArrayList<String>();

    // Fields in config.jelly must match the parameter names in the "DataBoundConstructor"
    @DataBoundConstructor
    public LogInfoBuilder(String key, boolean start) {
        settings.setKey(key);
        settings.setIsStart(start);
    }

    /**
     * We'll use this from the <tt>config.jelly</tt>.
     */
    public String getKey() {
        return settings.getKey();
    }

    public boolean isStart()
    {
        return settings.getIsStart();
    }

    ...
LogInfoBuilder扩展了公共类{
私有最终TimerSettings设置=新TimerSettings();
private final List infoCollection=new ArrayList();
//config.jelly中的字段必须与“DataBoundConstructor”中的参数名称匹配
@数据边界构造函数
公共LogInfoBuilder(字符串键,布尔开始){
设置。设置键(键);
settings.setIsStart(开始);
}
/**
*我们将从config.jelly中使用它。
*/
公共字符串getKey(){
返回设置;
}
公共布尔值isStart()
{
返回设置;
}
...
这些更改只包括更改变量的名称以适应config.jelly中给出的名称。

关键是使用“field”属性。在或中

关键是使用“字段”属性。在或中

关键是使用“字段”属性。在或中

关键是使用“字段”属性。在或中