JSF 循环重新渲染
希望标题不会太神秘...
我们遇到的问题是,我们从某些地方生成了一堆输入控件(h:inputOneMenu
、h:inputText
等) Java 列表。
工作正常,除非要求这些输入即时验证。 同样,这也不是那么难,只是因为控件是在循环中生成的,唯一可能的重新渲染操作基本上是整个表单或每个循环迭代周围的 a4j:outputPanel
,这基本上是相同的事情。
现在,上述两个解决方案在技术上是可行的,但它们具有重新渲染所有页面控件的令人讨厌的副作用,这使得页面感觉非常不稳定和笨重。 我们希望阻止这种情况发生,因此理想情况下,唯一重新渲染的控件是发送 ajax 更新/验证的控件。
基本上,这是我们的页面代码:
<ui:repeat value="#{seam-outjected-list}" var="item">
<a4j:outputPanel selfRendered="true">
<h:inputText value=#{item.value}>
<a4j:support event="onblur" ajaxSingle="true" />
</h:inputText>
</a4j:outputPanel>
</ui:repeat>
我遗漏了一些仅根据项目呈现不同控件的内容。
正如您所看到的,我们当前正在使用 a4j:outputPanel
解决方案,因此每次更新任何循环生成的控件时,所有控件都会重新渲染。
如果有人有任何想法,请提前致谢。
Hopefully the title isn't too cryptic ...
The problem we have is that we generate a bunch of input controls (h:inputOneMenu
, h:inputText
etc) from some Java List.
Works fine EXCEPT the requirement is that these inputs validate on the fly. Again not so hard except that as there controls were generated in a loop the only possible reRender action is basically the entire form or an a4j:outputPanel
around each loop iteration which is basically the same thing.
Now the above two solutions technically work but they have the nasty side effect of reRendering all the page controls which makes the page feel really twitchy and clunky. We'd like to stop this from happening so ideally the only control that gets reRendered is the control that send the ajax update/validation.
Basically this is our page code:
<ui:repeat value="#{seam-outjected-list}" var="item">
<a4j:outputPanel selfRendered="true">
<h:inputText value=#{item.value}>
<a4j:support event="onblur" ajaxSingle="true" />
</h:inputText>
</a4j:outputPanel>
</ui:repeat>
I've left out a bit of stuff that just renders different controls depending on the item.
As you can see we're currently using the a4j:outputPanel
solution so every time any loop generated control is updated all the controls are reRendered.
Thanks in advance if anyone has any thoughts.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的第一个想法是,您应该尝试用
替换
并利用ajaxKeys
> 属性仅重新渲染某些行。来自 Richfaces 文档:
My first thought is that you should try replacing your
<ui:repeat>
with an<a4j:repeat>
and take advantage of theajaxKeys
attribute to only reRender certain rows.From the Richfaces Docs: