Primefaces 显示绑定到p:dataTable迭代的元素的faces消息
我有一个分层模型,显示在用于编辑的嵌套表中:Primefaces 显示绑定到p:dataTable迭代的元素的faces消息,primefaces,Primefaces,我有一个分层模型,显示在用于编辑的嵌套表中: root (root bean) +- property1 (property of root) +- children (collection of child beans) +- property2 (property of child) +- subchildren (collection of subchild beans) +- property3 (property of subchild) 我正在对我的整个模型
root (root bean)
+- property1 (property of root)
+- children (collection of child beans)
+- property2 (property of child)
+- subchildren (collection of subchild beans)
+- property3 (property of subchild)
我正在对我的整个模型运行自定义验证,该验证通过以下路径将FacesMessages
添加到FacesContext
:
- 根
- 根:property1
- 根目录:子目录:0
- 根目录:子目录:0:属性2
- 根:子级:0:子级:0
- 根:子级:0:子级:0:属性3
- 根:子项:4:子项:3:属性3
FacesMessages
可以在每个级别(根bean、属性和集合中的bean)绑定
托管beanmyBean
保存着正在编辑的模型的根bean
为了编辑这个模型,我使用了类似这样的东西(简化到极限以显示我的问题):
儿童
*
物业2
亚儿童
...
为简单起见,表(*)的第一列用于显示当前行bean的验证消息(因此,在bean级别,如root:children:0,而不是在其属性上)
当使用标准html标记库(h:dataTable
)时,一切正常,我可以在各个级别看到验证消息
但是当我尝试使用primefaces表(p:dataTable/p:column/p:messages
)而不是(h:dataTable/h:column/h:messages
)时,我看不到集合中bean的验证消息:
- 根目录:子目录:0(未显示)
- 根:子级:0:子级:0(未显示)
- 根:子级:0:property2(显示)
- 根:子级:0:子级:0:属性3(显示)
ui:repeat
而不是h:dataTable
重写我的标记,那么一切都能正常工作,所以我认为问题出在primefaces上
也许我把事情推得有点太远了,幸运地让所有东西都能用ui:repeat
和h:dataTable
工作,但我想让它也能用primefaces工作,因为我想使用p:rowExpansion
我能做些什么来让它工作呢,还是说它是一个问题
感谢您阅读我的问题,召唤巴卢斯JSF神的咒语到这里来!:-) 请说明PF版本?如果将
h:messages
与p:dataTable
一起使用会怎么样?它失败了吗?PF出于这样或那样的原因决定让它们的重复组件(如p:dataTable
)不扩展默认的jsf UIData类,而是创建了它们自己的组件(如果我是对的,从PF 5.0开始)。从那时起,这些组成部分就有几个(对许多国际海事组织来说)问题。这也可能是其中之一(至少感觉与其他问题相关)。请在PF github中提交一个简单的问题。好的,谢谢,我会这样做。请参阅
<h:form id="root">
<h:messages for="root">
<h:inputText value="#{myBean.root.property1}" id="property1" />
<h:messages for="property1">
<h:dataTable value="#{myBean.root.children}" var="child" id="children">
<f:facet name="header">children</f:facet>
<h:column>
<f:facet name="header">*</f:facet>
<h:messages for="children" />
</h:column>
<h:column>
<f:facet name="header">property2</f:facet>
<h:inputText value="#{child.property2}" id="property2" />
<h:messages for="property2">
</h:column>
<h:column>
<f:facet name="header">subchildren</f:facet>
<h:dataTable value="#{child.subchildren}" var="subchild" id="subchildren">
...
</h:dataTable>
</h:column>
</h:dataTable>
</h:form>