简体   繁体   English

如何重新呈现a4j:repeat内的rich:dataTable?

[英]How to reRender a rich:dataTable which is inside a4j:repeat?

I have sth like this: 我有这样的事情:

<a4j:repeat value="#{results}" var="hdr" rowKeyVar="idx">
   <rich:dataTable var="item" value="#{results}" id="tbl#{idx}" first="#{idx}" rows="1">
       <a4j:commandButton value="update this table only" reRender="tbl#{idx}" />
   </rich:dataTable>
</a4j:repeat>

When I check from the output html, the data table has id like form:0:tbl that has no idx at the end. 当我从输出html检查时,数据表的ID像form:0:tbl一样,结尾没有idx。

The reRender will work when there is only one row in the results. 如果结果中只有一行,则reRender将起作用。

So here comes some questions: 因此,这里出现一些问题:

  1. Why doesn't dataTable's id works with EL expression while the "first" attribute works nicely? 为什么dataTable的ID不能与EL表达式一起使用,而“ first”属性却可以正常工作?
  2. How does reRender work that even I just specify tbl it can still be resolved while the actual HTML id is something longer like form:0:tbl? reRender如何工作,即使我只是指定tbl,它仍然可以解析,而实际的HTML id却像form:0:tbl一样长? (if I know how does reRender work, I maybe able to hack it to work with a4j:repeat...) (如果我知道reRender如何工作,我也许可以破解它以与a4j:repeat ...一起使用)
  3. Is there any technique or workaround that I could use to refresh only a specific dataTable that is inside a4j:repeat? 有什么技术或替代方法可以用来仅刷新a4j:repeat内的特定dataTable吗?

In fact I have successfully reRendered the whole a4j:repeat block surrounded by s:div. 实际上,我已经成功地重新渲染了s:div包围的整个a4j:repeat块。 But refreshing the whole block would reset the scrollbar so it isn't desired.... 但是刷新整个块会重置滚动条,所以这是不希望的。

For 1, it is possible that the life cycle of the table is in a different phase. 对于1,表的生命周期可能处于不同的阶段。

For 2, it refers to UIComponent.findComponent in fact for looking up a component given an ID. 对于2,它实际上是指UIComponent.findComponent,用于查找具有ID的组件。

For 3, perhaps try to use UIComponent.findComponent() or #{rich:clientId('id')} to see whether the actual HTML element ID of the a4j:repeat embedded rich:dataTable to be retrieved. 对于3,也许尝试使用UIComponent.findComponent()或#{rich:clientId('id')}来查看是否要检索a4j:repeat嵌入的rich:dataTable的实际HTML元素ID。

If yes, then somehow reRender can be made to work. 如果是,则可以使reRender正常工作。 If no, look if there is anything that can override how reRender looks for component. 如果没有,请检查是否有任何东西可以覆盖reRender查找组件的方式。

Okay latest experiment shows that simply using the rich:dataTable id can do. 好的最新实验表明,只需使用rich:dataTable id即可。

Keys to remember: 要记住的关键:

  1. Inside a4j:repeat, the absolute name of the id of dataTable will have something like :0: :1: for the corresponding index. 在a4j:repeat内,dataTable的ID的绝对名称将具有类似于:0::1:的对应索引。
  2. However, to locate it, simply using the same id as defined in rich:dataTable is okay. 但是,要找到它,只需使用与rich:dataTable中定义的相同的ID即可。 Don't append any suffix at the end. 不要在结尾添加任何后缀。
  3. When observing the ajax data from Chrome, the reRendered portion is just the same related dataTable of the component. 从Chrome观察ajax数据时,重新渲染的部分与组件的相关dataTable相同。

Conclusion, think too much, failed to try the simplest solution at the start. 结论,想得太多,一开始就没有尝试最简单的解决方案。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM