【发布时间】:2017-04-05 10:16:12
【问题描述】:
我有两个密切相关的问题:
- 我需要从主页的对话框中更新 ui:repeat 中标签内的表单,但无法弄清楚如何(因为 ui:repeat 中有很多标签,我只需要更新一个)
- 当我以这种形式使用 id 时,命名容器会搞砸并丢失它们的“索引”(以防试图确定更新路径表达式...)
我需要这个的原因:更新“wholelist”(当前情况)以某种方式破坏了<p:dialog> 内的所有<p:calendar>(没有错误...)(日历覆盖在第一次显示,但在更新列表之后它不再出现(必须重新加载页面)。另外,如果只能更改一个,我不想每次更新 100 个元素
page.xhtml
<h:panelGroup id="wholelist">
<ui:repeat var="entry" value="#{bean.foundEntries}" id="repeatId">
<customTag:someTag entry="#{entry}" />
</ui:repeat>
</h:panelGroup>
...
<p:dialog widgetVar="dialog" id="dialog">
<p:calendar value="#{bean.date}" ... /> <!-- overlay pops up on select until the whole list is refreshed. after that it does not appear until page reload -->
<p:commandButton actionlistener="#{bean.saveSomething()}" update="#{bean.componentToUpdate WHICH DOES NOT WORK...}"/>
</p:dialog>
someTag.xhtml
并在 <customTag:someTag> 内(这是一个标签,因为多次重复使用):
...
<h:form>
... display a lot of data which can be changed by the dialog...
<p:commandButton value="show edit dialog" onComplete="PF('dialog').show()" update=":dialog">
<f:setPropertyActionListener value="??? (@form does not work)" target="#{bean.componentToUpdate}" />
</p:commandButton>
</h:form>
第一个问题:
我需要从对话框中刷新一个表单(=该对话框需要知道我要刷新哪个表单,但我不知道该怎么做...)
我怎样才能使更新逻辑正常工作(将要更新的组件传递给 bean,以便对话框知道要更新或等于什么)?
第二个问题:
为什么 JSF 在没有定义 id="..." 到 ui 中的命名容器的情况下生成:重复类似
- repeatId:0:j_id_c0_6
- repeatId:1:j_id_c0_6
- repeatId:2:j_id_c0_6
当我为表单 (<h:form id="formname">) 定义一个 id 时,类似于
- repeatId:formname
- repeatId:formname
- repeatId:formname
导致duplicateId(因为名称中缺少“iterator-number”)?
这有意义吗?
【问题讨论】:
-
JSF 实现和版本信息? p:dialog 是否相关?或所有 PrimeFaces 组件
-
MyFaces,JSF 2.0。我认为 p:dialog 不相关 - 它应该强调必须从根 xhtml 页面访问/更新表单,而不是从自定义标签或其他任何内容。 Primefaces 是相关的,因为刷新后 p:calendar 会中断,这就是我打开问题的原因。
-
p:calendar 如果您在保存时更新 ":wholelist" 将停止工作并重试(第二个对话框中的 p:calendar 无效)
-
JSF-2.0 是 SPEC,不是 2.0.x 的实现版本
-
日历在重复之外和之后。因此,如果由于“中断”之前的某些事情而中断,则它与日历无关。
标签: ajax jsf primefaces naming-containers