JSF 循环重新渲染

发布于 2024-07-27 23:19:06 字数 859 浏览 3 评论 0原文

希望标题不会太神秘...

我们遇到的问题是,我们从某些地方生成了一堆输入控件(h:inputOneMenuh: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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

扛起拖把扫天下 2024-08-03 23:19:06

我的第一个想法是,您应该尝试用 替换 并利用 ajaxKeys > 属性仅重新渲染某些行。

来自 Richfaces 文档

该组件的主要区别
来自其他迭代组件
库是一个特殊的“ajaxKeys”
属性。 该属性定义行
Ajax 之后更新的键
要求。 结果变得更容易
更新多个子组件
单独更新而不更新整体
页。

My first thought is that you should try replacing your <ui:repeat> with an <a4j:repeat> and take advantage of the ajaxKeys attribute to only reRender certain rows.

From the Richfaces Docs:

The main difference of this component
from iterative components of other
libraries is a special "ajaxKeys"
attribute. This attribute defines row
keys that are updated after an Ajax
request. As a result it becomes easier
to update several child components
separately without updating the whole
page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文