org.kohsuke.stapler.StaplerRequest.bindParametersToList()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(68)

本文整理了Java中org.kohsuke.stapler.StaplerRequest.bindParametersToList()方法的一些代码示例,展示了StaplerRequest.bindParametersToList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.bindParametersToList()方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:bindParametersToList

StaplerRequest.bindParametersToList介绍

[英]Binds collection form parameters to beans by using introspection or constructor parameters injection.

This method works like #bindParameters(Object,String) and #bindParameters(Class,String), but it assumes that form parameters have multiple-values, and use individual values to fill in multiple beans.

For example, if getParameterValues("foo")=={"abc","def"} and getParameterValues("bar")=={"5","3"}, then this method will return two objects (the first with "abc" and "5", the second with "def" and "3".)
[中]通过使用内省或构造函数参数注入将集合表单参数绑定到bean。
该方法的工作原理类似于#bindParameters(对象、字符串)和#bindParameters(类、字符串),但它假定表单参数有多个值,并使用单个值填充多个bean。
例如,如果getParameterValues(“foo”)=={abc”,“def”}和getParameterValues(“bar”)={5”,“3”},那么这个方法将返回两个对象(第一个带有“abc”和“5”,第二个带有“def”和“3”。)

代码示例

代码示例来源:origin: jenkinsci/envinject-plugin

@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  List<EnvInjectGlobalPasswordEntry> envInjectGlobalPasswordEntriesList = req.bindParametersToList(EnvInjectGlobalPasswordEntry.class, "envInject.");
  envInjectGlobalPasswordEntries = envInjectGlobalPasswordEntriesList.toArray(new EnvInjectGlobalPasswordEntry[envInjectGlobalPasswordEntriesList.size()]);
  save();
  return true;
}

代码示例来源:origin: jenkinsci/testlink-plugin

@Override
public boolean configure(StaplerRequest req, JSONObject json) throws hudson.model.Descriptor.FormException {
  this.installations = req.bindParametersToList(TestLinkInstallation.class, "TestLink.").toArray(
      new TestLinkInstallation[0]);
  save();
  return true;
}

代码示例来源:origin: org.jenkins-ci.plugins/s3

@Override
public boolean configure(StaplerRequest req, net.sf.json.JSONObject json) throws FormException {
  profiles.replaceBy(req.bindParametersToList(S3Profile.class, "s3."));
  save();
  return true;
}

代码示例来源:origin: org.jenkins-ci.plugins/rake

@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
  installations = req.bindParametersToList(RubyInstallation.class, "rake.")
    .toArray(new RubyInstallation[0]);
  rvm = req.bindParameters(Rvm.class, "rvm.");
  installations = getGlobalRubies(rvm, installations);
  save();
  return true;
}

代码示例来源:origin: jenkinsci/cobertura-plugin

/**
 * Creates a new instance of {@link CoberturaPublisher} from a submitted form.
 */
@Override
public CoberturaPublisher newInstance(StaplerRequest req, JSONObject formData) throws FormException {
  // Null check because findbugs insists, despite the API guaranteeing this is never null.
  if (req == null) {
    throw new FormException("req cannot be null", "");
  }            
  CoberturaPublisher instance = req.bindJSON(CoberturaPublisher.class, formData);
  ConvertUtils.register(CoberturaPublisherTarget.CONVERTER, CoverageMetric.class);
  List<CoberturaPublisherTarget> targets = req
      .bindParametersToList(CoberturaPublisherTarget.class, "cobertura.target.");
  if (0 == targets.size()) {
    targets = bindTargetsFromForm(formData);
  }
  try {
    instance.setTargets(targets);
  } catch (AbortException ex) {
    Logger.getLogger(CoberturaPublisher.class.getName()).log(Level.SEVERE, null, ex);
  }
  return instance;
}

代码示例来源:origin: jenkinsci/log-parser-plugin

@Override
  public boolean configure(final StaplerRequest req, final JSONObject json)
      throws FormException {
    parsingRulesGlobal = req.bindParametersToList(ParserRuleFile.class,
        "log-parser.").toArray(new ParserRuleFile[0]);
    useLegacyFormatting = json.getJSONObject("log-parser").getBoolean(
        "useLegacyFormatting");
    save();
    return true;
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/port-allocator

@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
  Pool[] pools = req.bindParametersToList(Pool.class, "pool.").toArray(new Pool[] {});
  for (Pool p : pools) {
    p.name = checkPoolName(p.name);
    checkPortNumbers(p.ports);
  }
  this.pools = pools;
  save();
  return super.configure(req,formData);
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法