我正在使用DataTable,我在页脚中显示EL值时遇到了一些麻烦。 我已经制作了我的xhtml的简化版本,仍然可以重现错误。
如果我像这样执行p:dataTable这一切都有效:
<p:dataTable value="#{myMB.items}" var="item"> <p:column headerText="Value" footerText="Value"> <h:outputText value="#{item.value}"> <f:convertNumber pattern="###,##0.00"/> </h:outputText> </p:column> </p:dataTable>我得到了这个结果:
页脚显示就好了。 然后我用EL尝试它,改变列定义如下:
<p:column headerText="Value" footerText="#{3 + 11}"> <h:outputText value="#{item.value}"> <f:convertNumber pattern="###,##0.00"/> </h:outputText> </p:column>它评估我的表达式,我得到了这个结果:
它在页脚中显示正确的值14 。 但是当我尝试使用模型中的值时,它没有显示出来。 看例子:
代码 :
<p:column headerText="Value" footerText="#{item.value}"> <h:outputText value="#{item.value}"> <f:convertNumber pattern="###,##0.00"/> </h:outputText> </p:column>输出 :
我试图以不同的方式做页脚。 没有一次尝试有效。
有没有正确的方法来做到这一点? 在展示它似乎工作得很好。
我正在使用PrimeFaces 3.3.1
I'm working with a DataTable, and I'm having some trouble displaying a value from an EL in the footer. I have made a simplified version of my xhtml that still reproduces the error.
If I do the p:dataTable like this it all works:
<p:dataTable value="#{myMB.items}" var="item"> <p:column headerText="Value" footerText="Value"> <h:outputText value="#{item.value}"> <f:convertNumber pattern="###,##0.00"/> </h:outputText> </p:column> </p:dataTable>I get this as a result:
The footer shows just fine. And then I try it with EL, changing the column definition like this:
<p:column headerText="Value" footerText="#{3 + 11}"> <h:outputText value="#{item.value}"> <f:convertNumber pattern="###,##0.00"/> </h:outputText> </p:column>And it evaluates my expression, I get this as a result:
It shows the correct value 14 in the footer. But when I try to use a value from my model, it doesn't show. See the example:
Code:
<p:column headerText="Value" footerText="#{item.value}"> <h:outputText value="#{item.value}"> <f:convertNumber pattern="###,##0.00"/> </h:outputText> </p:column>Output:
And I have tried to do the footer in different ways. Not a single attempt worked.
Is there a correct way to do this? In the showcase it seems to work just fine.
I am using PrimeFaces 3.3.1
最满意答案
问题是缺乏关注。
我没有意识到单个页脚有多个列值。 由于JSF无法决定单个值,因此它没有显示任何内容。
我发布后不久,答案就出现了。 我试图在我的ManagedBean上定义一个值作为页脚使用,它工作得很好。
同样,JSF和/或PrimeFaces没有任何问题,我的缺乏逻辑思维。
它适用于展示,因为它显示实际上每个值都有一个页脚的子表。
The problem was lack of attention.
I failed to realize that I have multiple column values for a single footer. And since JSF can't decide on a single value, it shows nothing.
Shortly after I posted this the answer came to me. I tried to define a single value on my ManagedBean to use as footer, and it work just fine.
Again, there's nothing wrong with JSF and/or PrimeFaces, it was just lack of logical thinking from my part.
It works on the showcase, because it shows subtables that actually do have a footer for each value.
更多推荐
发布评论