如何处理 "transient" 个没有支持 bean 表示的输入元素?

How to deal with "transient" input elements that have no backing bean representation?

我遇到过一些使用没有 value 属性集的输入控件的情况,即它们在支持 bean 中没有直接表示。

用户输入完全由 ajax 听众处理。例如 column filters in the primefaces table.

的输入元素

但是,在处理此类输入字段时,MyFaces 会警告我以下各项:

    Feb 09, 2017 3:04:51 PM javax.faces.validator.BeanValidator validate
    WARNING: cannot validate component with empty value: my_form:myTableId:j_id_1s

在某种程度上,这里已经提到了这个问题:

我的问题是:在这种情况下,最佳做法是什么?

  1. 输入元素应该总是在支持bean中有一个引用,其他都是设计错误
  2. 只需使用指向 bean 中未使用字段的 "dummy" 值。
  3. 禁止验证该输入元素。 (如何?)
  4. 以某种方式抑制 MyFaces 警告。 (如何?)

1. An input element should always have a reference in the backing bean, everything else is a design error

不正确。


2. Just use a "dummy" value that points to an unused field in the bean.

没有。这在短期内是荒谬的,从长远来看充其量是令人困惑的。


3. Suppress the validation of that input element. (How?)

你可以的。您可以为此使用 <f:validateBean>

<h:inputXxx>
    <f:validateBean disabled="true" />
</h:inputXxx>

4. Suppress the MyFaces warning somehow. (How?)

基于 its source code there doesn't seem to be any way. You'd best ask them 仅在 Development 阶段记录。