简体   繁体   English

c:forEach vs ui:repeat(又名 ice:panelSeries)

[英]c:forEach vs ui:repeat (a.k.a ice:panelSeries)

I'm trying to avoid using c:forEach because I heard that JSTL doesn't mix well into the render phase of the JSF... I'm not sure of that claim at all.我试图避免使用 c:forEach,因为我听说 JSTL 不能很好地融入 JSF 的渲染阶段......我完全不确定这个说法。 On the contrary I had to resort to using c:forEach instead of ui:repeat in many cases because the ui:repeate simply does NOT iterate on the collection.. this happened in many cases that I cannot isolate the reason, and in all of these cases c:forEach was a very well behaved replacement.相反,在许多情况下,我不得不使用 c:forEach 而不是 ui:repeat 因为 ui:repeate 根本不迭代集合。在这些情况下, c:forEach 是一个表现非常好的替代品。 My question is about the one case in which c:forEach is not behaving well, and ui:repeat is not returning anything from the collection (even though it repeats the decorating html tags the correct number of times).我的问题是关于 c:forEach 表现不佳的一种情况,并且 ui:repeat 没有从集合中返回任何内容(即使它重复装饰 html 标签的次数正确)。

What happens is that sometimes the JSF components created inside the c:forEach get scattered all over the page, leaving the decorating HTML tags in the body of the c:forEach empty and getting rendered else where in the page.发生的情况是,有时在 c:forEach 中创建的 JSF 组件散布在整个页面中,使 c:forEach 主体中的装饰 HTML 标记为空,并在页面中的其他位置呈现。 This happens only some times and specially when doing a refresh using F5 (which gets fixed most of the times with a subsequent refresh using Ctrl+F5).这只会发生在某些时候,特别是在使用 F5 进行刷新时(大多数情况下,使用 Ctrl+F5 进行刷新时会得到修复)。

I am totally perplexed and would appreciate any ideas about what is happening.. why is ui:repeat (and ice:panelSeries) not getting back the values from the collection??我完全感到困惑,并希望了解有关正在发生的事情的任何想法..为什么 ui:repeat(和 ice:panelSeries)没有从集合中取回值? why is c:forEach scattering is content all over the place (seems like a race condition while building the JSf component tree.. maybe the rendered should wait for c:forEach and it doesn't)??为什么 c:forEach 散射是整个地方的内容(在构建 JSf 组件树时似乎是竞争条件......也许渲染应该等待 c:forEach 而它没有)?? Why did it happen only in this case??为什么只发生在这种情况下??

I am sorry that I am not including any code snippets or screen shots because I don't know what to include.. the problem is too general.很抱歉我没有包含任何代码片段或屏幕截图,因为我不知道要包含什么......问题太笼统了。 But you can be quite confider that my syntax is correct... I already checked that.. and I don't use the status variable (which causes too much trouble in ui:repeat).但是你可以确信我的语法是正确的......我已经检查过了......而且我没有使用状态变量(这会在 ui:repeat 中造成太多麻烦)。

ui:repeate simply does NOT iterate on the collection ui:repeate 只是不迭代集合

The following code works:以下代码有效:

<ui:repeat value="#{myCollection}" var="item">  
   <h:outputText value="#{item}" />
</ui:repeat>

Why did it happen only in this case??为什么只发生在这种情况下??

without an example of this case it's hard to know..没有this case的例子,很难知道..

However, c:forEach vs ui:repeat document may help you to find a reason.但是, c:forEach 与 ui:repeat 文档可能会帮助您找到原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JSF 中的递归(c:forEach 与 ui:repeat) - Recursion in JSF (c:forEach vs. ui:repeat) 替换c:foreach on ui:repeat - Replace c:foreach on ui:repeat 什么时候<ui:repeat>适用于 X 但<c:forEach>为 Y 工作 - When <ui:repeat> works for X but <c:forEach> works for Y 业务方法中的错误检查,也称为防御性编程 - Error checking in business methods a.k.a doing defensive programming 使用Java的Selenium WebDriver(aka Selenium2)中的getPageSource() - getPageSource() in Selenium WebDriver(a.k.a Selenium2) using Java 需要SWT通知动画框(又名烤面包机) - SWT Notification animated box (a.k.a toaster) needed 在ui:include中使用c:foreach的问题 - Problems using c:foreach with ui:include 通过Maven aka作为Maven驱动的功能翻转释放时禁用Lombok日志记录 - Disable lombok logging when releasing via maven a.k.a as maven driven feature flipping 列出目录中与文件掩码(又名模式或 Glob)匹配的所有文件 - List all Files from a Directory that match a File Mask (a.k.a Pattern or Glob) Java中的动态范围变量? (又称每个方法执行一个变量) - Dynamically scoped variable in java ? (a.k.a one variable per method execution)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM