java 当 <ui:repeat> 适用于 X 而 <c:forEach> 适用于 Y

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4213681/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 05:20:53  来源:igfitidea点击:

When <ui:repeat> works for X but <c:forEach> works for Y

javajsfjstl

提问by Marcel Menz

I use <c:foreach>in my jsf app to iterate over a list of people. I don't use <ui:repeat>because every person has its own tab (primefaces). JSF hero 'BalusC' already helped my out on this one link. Now I tried to save (postback) the data. This doesn't work with <c:forEach>, the approriate setter of the Person object gets never called. With <ui:repeat>it works. Obviously I haven't grasped the difference between the two tags so I would appriciate some enlightenment.

<c:foreach>在我的 jsf 应用程序中使用迭代人员列表。我不使用,<ui:repeat>因为每个人都有自己的选项卡(primefaces)。JSF 英雄 'BalusC' 已经帮助我解决了这个链接。现在我尝试保存(回发)数据。这不适用于<c:forEach>,Person 对象的适当 setter 永远不会被调用。有了<ui:repeat>它。显然我还没有掌握这两个标签之间的区别,所以我会得到一些启发。

Thanks

谢谢

Marcel

马塞尔

采纳答案by mcosta

<c:forEach>does not build JSF tree nodes on the server. You can see this directly in the html, the inputs do nothave the usual long and distinct id="j_12:customerTabPanel:j_34:customerName".

<c:forEach>不在服务器上构建 JSF 树节点。您可以直接在 html 中看到这一点,输入没有通常的 long 和 distinct id="j_12:customerTabPanel:j_34:customerName"

Please, read this:

请阅读这个:

http://www.ninthavenue.com.au/blog/c:foreach-vs-ui:repeat-in-facelets

http://www.ninthavenue.com.au/blog/c:foreach-vs-ui:repeat-in-facelets

回答by Romain Linsolas

<c:***>tags are build-time tags, as <ui:***>are rendered-time tags. To get the difference between these two concepts, I recommand you to read the two links below:

<c:***>标签是构建时标签,<ui:***>渲染时标签也是如此。要了解这两个概念之间的区别,我建议您阅读以下两个链接: