【发布时间】:2016-03-30 18:23:44
【问题描述】:
假设我基本上使用rendered 作为案例陈述。我有一个输入字段的标签和消息,但我希望字段本身根据情况而变化。因此:
<p:inputText id="foo" value="#{myBean.params[paramKey]}"
rendered="#{paramIsInput}" />
<p:calendar id="foo" value="#{myBean.params[paramKey]}"
rendered="#{paramIsCalendar}" />
如果我这样做,我会收到以下错误:java.lang.IllegalStateException: Component ID j_idt64:foo has already been found in the view.
作为一种解决方法,我为每种参数类型创建了许多标签/消息并更改了它们的 ID。但这带来了我的问题。如果实际上只渲染了一个具有 id 的组件,为什么我在我的 jsf 文件中定义了多个组件呢?有没有办法让它们保持相同的 ID?
【问题讨论】:
-
考虑
paramIsInput和paramIsCalendar都为真的用例...... -
更改您的
<p:inputText>或<p:calendar>的ID。即使控件没有渲染,它们也不能有相同的 id。 -
@SiB 我实际上对每个参数进行了检查,因此它们只能有 1 个 true。这不是问题
-
@DMoses 你知道......这不能用于在编写规范时做出决策:)
标签: jsf duplicates identifier illegalstateexception