【问题标题】:Programmatically adding JSF components without binding to backing bean property以编程方式添加 JSF 组件而不绑定到支持 bean 属性
【发布时间】:2016-03-03 03:06:58
【问题描述】:

我正在直接从 bean 中以编程方式添加一些 uiinput 组件,如下所示:

UIInput uiField = (HtmlInputText) application.createComponent(HtmlInputText.COMPONENT_TYPE);
uiField.setId(fieldId);

请注意,我不想将此组件绑定到任何 bean 属性。

问题是,当通过 id 检索组件时,即使在表单中填充字段并提交表单后,该值也始终为 null。

UIInput uiField = (UIInput) facesContext.getViewRoot().findComponent(fieldId);
String value = uiField.getValue().toString(); //null

请指教。

【问题讨论】:

    标签: java jsf jsf-2 primefaces richfaces


    【解决方案1】:

    我发现我必须将组件放入表单中。

    【讨论】:

      猜你喜欢
      • 2012-04-01
      • 2013-03-27
      • 2011-06-29
      • 2011-12-31
      • 2012-07-16
      • 2011-10-15
      • 2012-06-19
      • 2011-06-26
      • 2011-07-14
      相关资源
      最近更新 更多